|
|
|
|
3
|
import org.springframework.boot.SpringApplication;
|
3
|
import org.springframework.boot.SpringApplication;
|
4
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
4
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
5
|
import org.springframework.context.annotation.Bean;
|
5
|
import org.springframework.context.annotation.Bean;
|
|
|
6
|
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
6
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
7
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
|
8
|
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
7
|
|
9
|
|
8
|
@SpringBootApplication
|
10
|
@SpringBootApplication
|
9
|
public class DemoApplication {
|
11
|
public class DemoApplication {
|
|
|
|
|
11
|
public static void main(String[] args) {
|
13
|
public static void main(String[] args) {
|
12
|
SpringApplication.run(DemoApplication.class, args);
|
14
|
SpringApplication.run(DemoApplication.class, args);
|
13
|
}
|
15
|
}
|
|
|
16
|
+
|
|
|
17
|
+ @Bean
|
|
|
18
|
+ public WebMvcConfigurer corsConfigurer() {
|
|
|
19
|
+ return new WebMvcConfigurerAdapter() {
|
|
|
20
|
+ @Override
|
|
|
21
|
+ public void addCorsMappings(CorsRegistry registry) {
|
|
|
22
|
+ registry.addMapping("*").allowedOrigins("http://localhost:9000");
|
|
|
23
|
+ }
|
|
|
24
|
+ };
|
|
|
25
|
+ }
|
14
|
}
|
26
|
}
|