lu914596513 преди 6 години
родител
ревизия
22d74d4041
променени са 2 файла, в които са добавени 23 реда и са изтрити 0 реда
  1. 3 0
      src/main/java/com/bjlt/spider/UserServiceApplication.java
  2. 20 0
      src/main/java/com/bjlt/spider/config/CorsConfig.java

+ 3 - 0
src/main/java/com/bjlt/spider/UserServiceApplication.java

@@ -1,5 +1,6 @@
 package com.bjlt.spider;
 
+import com.bjlt.spider.entity.SourceEnum;
 import com.luyn.config.LuynConfig;
 import com.luyn.http.config.HttpConfig;
 import com.luyn.http.debug.Debug;
@@ -25,6 +26,8 @@ public class UserServiceApplication {
         /**
          * 日志打印配置
          */
+
+        SourceEnum.VJ_APP.
 //        LuynConfig.setHttpClientDebug_Level(Debug.Level.ALL);
 //        HttpConfig.setDebug(Debug.Level.ALL);
 //        LuynConfig.setHttpClientDebug_Level(Debug.Level.ALL);

+ 20 - 0
src/main/java/com/bjlt/spider/config/CorsConfig.java

@@ -0,0 +1,20 @@
+package com.bjlt.spider.config;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.CorsRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+
+@Configuration
+public class CorsConfig extends WebMvcConfigurerAdapter {
+
+    @Override
+    public void addCorsMappings(CorsRegistry registry) {
+
+
+        registry.addMapping("/**")
+                .allowedOrigins("*")
+                .allowCredentials(true)
+                .allowedMethods("GET", "POST", "DELETE", "PUT")
+                .maxAge(3600);
+    }
+
+}