SpringBoot解决Swagger2出现No mapping for GET /swagger-ui.html
springBoot配置Swagger2出现页面无法访问错误:No mapping for GET /swagger-ui.html
如果继承了WebMvcConfigurationSupport,则在yml中配置的相关内容会失效。 需要重新指定静态资源
在当前继承WebMvcConfigurationSupport、WebMvcConfigurer的配置类加上如下代码:
@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/");
addResourceHandlers(registry);
}
至此完成配置