webmvc与swagger页面冲突问题
场景:添加了webmvcconfig之后,swagger默认的页面访问变成404
原因:swagger静态资源映射走了自动装配,手动添加webmvcconfig之后,自动配置失效。
解决办法:手动添加swagger静态资源映射
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
registry.addResourceHandler("/**").addResourceLocations("classpath:/META-INF/resources/",
"classpath:/resources/", "classpath:/static/", "classpath:/public/");
}
参考文章:https://blog.csdn.net/Kerwin_luo/article/details/114266444