본문 바로가기
Spring Boot

[Swagger] swagger-ui.html 접속 url 변경하기 (리다이렉트)

by palbokdev 2023. 8. 9.
@SpringBootApplication
public class MyApp {
	public static void main(String[] args) {
		SpringApplication.run(MyApp.class, args);
	}

	@Bean
	RouterFunction<ServerResponse> routerFunction() {
		return route(GET("/swagger"), req ->
			ServerResponse.temporaryRedirect(URI.create("swagger-ui.html")).build());
	}
}

위와 같이 빈으로 등록해주면, localhost:8080/swagger로 접속하였을때

localhost:8080/swagger-ui.html로 리다이렉트 해줍니다.

 

ref : https://github.com/springfox/springfox/issues/2250