解决springboot跨域问题

主要是在application启动项中添加一段代码,允许该IP地址进行访问,多个IP用逗号隔开
public class Application {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Bean
    public WebMvcConfigurer corsConfigurer() {
        return new WebMvcConfigurerAdapter() {
            @Override
            public void addCorsMappings(CorsRegistry registry) {
                registry.addMapping("/**").allowedOrigins("http://192.168.1.17:8088", "http://192.168.1.18:8088", "http://192.168.1.19:8088");
            }
        };
    }


}

猜你喜欢

转载自blog.csdn.net/wanjunsnow/article/details/80647396