跨域
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter{
@Autowired
private AuthInterceptor authInterceptor;
@Autowired
private UserParameterResolver userParameterResolver;
@Override
public void addInterceptors(InterceptorRegistry registry) {
//registry.addInterceptor(authInterceptor).addPathPatterns("/**");
super.addInterceptors(registry);
}
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
argumentResolvers.add(userParameterResolver);
super.addArgumentResolvers(argumentResolvers);
}
// 增加这句
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedOrigins("*");
}
}
配置静态文件访问
spring:
mvc:
date-format: ${custom.common-date-format}
static-path-pattern: "/**"