에러
- Swagger 적용 후 브라우저에서 http://localhost:8080/swagger-ui.html 접속하면 Whitelabel Error Page 발생
2023-04-14 19:28:50.703 DEBUG 32252 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : GET "/swagger-ui.html", parameters={}
2023-04-14 19:28:50.709 DEBUG 32252 --- [nio-8080-exec-1] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped to ResourceHttpRequestHandler [classpath [META-INF/resources/], classpath [resources/], classpath [static/], classpath [public/], ServletContext [/]]
2023-04-14 19:28:50.714 DEBUG 32252 --- [nio-8080-exec-1] o.s.w.s.r.ResourceHttpRequestHandler : Resource not found
2023-04-14 19:28:50.714 DEBUG 32252 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed 404 NOT_FOUND
2023-04-14 19:28:50.718 DEBUG 32252 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : "ERROR" dispatch for GET "/error", parameters={}
2023-04-14 19:28:50.719 DEBUG 32252 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController#errorHtml(HttpServletRequest, HttpServletResponse)
2023-04-14 19:28:50.742 DEBUG 32252 --- [nio-8080-exec-1] o.s.w.s.v.ContentNegotiatingViewResolver : Selected 'text/html' given [text/html, text/html;q=0.8]
2023-04-14 19:28:50.746 DEBUG 32252 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Exiting from "ERROR" dispatch, status 404
- build.gradle
dependencies {
implementation 'io.springfox:springfox-swagger-ui:3.0.0'
implementation 'io.springfox:springfox-swagger2:3.0.0'
}
해결방법
- http://localhost:8080/v2/api-docs → 정상적으로 작동
- http://localhost:8080/swagger-resources → 정상적으로 작동
- build.gradle에 아래 코드 추가
implementation 'io.springfox:springfox-boot-starter:3.0.0'
- http://localhost:8080/swagger-ui/index.html 접속
- Swagger이 3.0.0을 사용하면 URL 주소가 이전에 사용하던 http://localhost:8080/swagger-ui.html와 다르고, build.gradle에도 다른 dependency를 추가해야 한다.