yml或properties检查是否添加了这个配置: Ctrl+F 搜索一下
resources:
add-mappings: false
如果存在,那么极有可能就是它了,使静态资源访问
解决方法一:
去除
解决方法二:
添加
@Component public class WebSecurityConfigStaticFree implements WebMvcConfigurer { @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/swagger-ui.html") .addResourceLocations("classpath:/META-INF/resources/", "/static", "/public"); registry.addResourceHandler("/webjars/**") .addResourceLocations("classpath:/META-INF/resources/webjars/"); } }