记录一下 学习spring boot 遇到的问题
swagger2
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
}
swagger 添加此配置之后仍然404
1.有可能是 有其他类 实现了 WebMvcConfigurer 或者 继承了 WebMvcConfigurationSupport
导致的
WebMvcConfigurationSupport 在继承的时候 没有重写addResourceHandlers
2.spring boot 启动模式有三种 如果默认没有改动的话 应该是 SERVLET
NONE,
SERVLET,
REACTIVE;
注意查看 只有SERVLET 会加载webmvc配置