No mapping for GET /swagger-ui.html
问题描述:
-
springboot项目中使用swagger2输出接口文档,在浏览器输入http://localhost/swagger-ui.html 无法进入swagger-ui页面。如下图:
-
IDEA调试窗口输出 No mapping for GET /swagger-ui.html 。如下图:
原因:
- 在yml文件中配置了static-path-pattern或者在其它地方配置staticPathPattern。 如下图:
解决方法
把Swagger的配置类继承WebMvcConfigurer,并重写addResourceHandlers方法。如下图: