张涛 1 ano atrás
pai
commit
5fe6145613

+ 1
- 2
src/main/java/com/example/civilizedcity/CivilizedCityApplication.java Ver arquivo

2
 
2
 
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.ComponentScan;
6
 import org.springframework.scheduling.annotation.EnableAsync;
5
 import org.springframework.scheduling.annotation.EnableAsync;
7
 import org.springframework.transaction.annotation.EnableTransactionManagement;
6
 import org.springframework.transaction.annotation.EnableTransactionManagement;
8
 
7
 
9
 @EnableAsync
8
 @EnableAsync
10
-@EnableTransactionManagement
9
+@EnableTransactionManagement(proxyTargetClass = true)
11
 @SpringBootApplication
10
 @SpringBootApplication
12
 public class CivilizedCityApplication {
11
 public class CivilizedCityApplication {
13
 
12
 

+ 56
- 61
src/main/java/com/example/civilizedcity/config/CorsFilter.java Ver arquivo

1
-package com.example.civilizedcity.config;
2
-
3
-import java.io.IOException;
4
-
5
-import javax.servlet.Filter;
6
-import javax.servlet.FilterChain;
7
-import javax.servlet.FilterConfig;
8
-import javax.servlet.ServletException;
9
-import javax.servlet.ServletRequest;
10
-import javax.servlet.ServletResponse;
11
-import javax.servlet.http.HttpServletRequest;
12
-import javax.servlet.http.HttpServletResponse;
13
-
14
-import org.springframework.core.annotation.Order;
15
-import org.springframework.stereotype.Component;
16
-
17
-/**
18
- * 跨域过滤器
19
- * @author click33
20
- */
21
-@Component
22
-@Order(-200)
23
-public class CorsFilter implements Filter {
24
-
25
-    static final String OPTIONS = "OPTIONS";
26
-
27
-    @Override
28
-    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
29
-            throws IOException, ServletException {
30
-        HttpServletRequest request = (HttpServletRequest) req;
31
-        HttpServletResponse response = (HttpServletResponse) res;
32
-
33
-        // 允许指定域访问跨域资源
34
-        response.setHeader("Access-Control-Allow-Origin", "*");
35
-        // 允许所有请求方式
36
-        response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE,PUT");
37
-        // 有效时间
38
-        response.setHeader("Access-Control-Max-Age", "3600");
39
-        // 允许的header参数
40
-        response.setHeader("Access-Control-Allow-Headers", "*");
41
-
42
-        // 如果是预检请求,直接返回
43
-        if (OPTIONS.equals(request.getMethod())) {
44
-            System.out.println("=======================浏览器发来了OPTIONS预检请求==========");
45
-            response.getWriter().print("");
46
-            return;
47
-        }
48
-
49
-        // System.out.println("*********************************过滤器被使用**************************");
50
-        chain.doFilter(req, res);
51
-    }
52
-
53
-    @Override
54
-    public void init(FilterConfig filterConfig) {
55
-    }
56
-
57
-    @Override
58
-    public void destroy() {
59
-    }
60
-
61
-}
1
+//package com.example.civilizedcity.config;
2
+//
3
+//import org.springframework.core.annotation.Order;
4
+//import org.springframework.stereotype.Component;
5
+//
6
+//import javax.servlet.FilterConfig;
7
+//import javax.servlet.*;
8
+//import javax.servlet.http.HttpServletRequest;
9
+//import javax.servlet.http.HttpServletResponse;
10
+//import java.io.IOException;
11
+//
12
+///**
13
+// * 跨域过滤器
14
+// * @author click33
15
+// */
16
+//@Component
17
+//@Order(-200)
18
+//public class CorsFilter implements Filter {
19
+//
20
+//    static final String OPTIONS = "OPTIONS";
21
+//
22
+//    @Override
23
+//    public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
24
+//            throws IOException, ServletException {
25
+//        HttpServletRequest request = (HttpServletRequest) req;
26
+//        HttpServletResponse response = (HttpServletResponse) res;
27
+//
28
+//        // 允许指定域访问跨域资源
29
+//        response.setHeader("Access-Control-Allow-Origin", "*");
30
+//        // 允许所有请求方式
31
+//        response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE,PUT");
32
+//        // 有效时间
33
+//        response.setHeader("Access-Control-Max-Age", "3600");
34
+//        // 允许的header参数
35
+//        response.setHeader("Access-Control-Allow-Headers", "*");
36
+//
37
+//        // 如果是预检请求,直接返回
38
+//        if (OPTIONS.equals(request.getMethod())) {
39
+//            System.out.println("=======================浏览器发来了OPTIONS预检请求==========");
40
+//            response.getWriter().print("");
41
+//            return;
42
+//        }
43
+//
44
+//        // System.out.println("*********************************过滤器被使用**************************");
45
+//        chain.doFilter(req, res);
46
+//    }
47
+//
48
+//    @Override
49
+//    public void init(FilterConfig filterConfig) {
50
+//    }
51
+//
52
+//    @Override
53
+//    public void destroy() {
54
+//    }
55
+//
56
+//}