以前在整合项目的时候经常遇到这个问题,但是能托就托,没怎么在意,今天需要整合Ueditor,但是JS文件依然没法显示,因此在这里解决了一下
//开启全局方法验证
@Configuration
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class GlobalMethodSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/static/**","/favicon.ico");
}
}
@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {
/**
* 配置静态资源
* @param registry
*/
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
super.addResourceHandlers(registry);
}
}
# mvc: #直接定义过滤规则与静态资源位置
# static-path-pattern: /static/**
# resources:
# static-locations: classpath:/static/