问题:
SpringBoot配置Swagger2出现页面无法访问错误 :No mapping for GET /swagger-ui.html
解决:
如果继承了WebMvcConfigurationSupport,则在yml中配置的相关内容会失效;需重新指定静态资源路径映射。
在当前继承WebMvcConfigurationSupport的配置类加上如下代码:
@Override public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**").addResourceLocations( "classpath:/static/");
registry.addResourceHandler("swagger-ui.html").addResourceLocations(
"classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**").addResourceLocations(
"classpath:/META-INF/resources/webjars/"); super.addResourceHandlers(registry);
}