再在SecurityConfig类(继承WebSecurityConfigurerAdapter)中
@Bean
CorsConfigurationSource corsConfigurationSource(){
return httpServletRequest -> {
CorsConfiguration cfg = new CorsConfiguration();
cfg.addAllowedHeader("*");
cfg.addAllowedMethod("*");
cfg.addAllowedOrigin("http://localhost:9528");
cfg.setAllowCredentials(true);
cfg.checkOrigin("http://localhost:9528");
return cfg;
};
}