lengfaqiang 2 лет назад
Родитель
Сommit
e428d7c5d0

+ 4 - 0
sckw-common/sckw-common-seata/pom.xml

@@ -18,6 +18,10 @@
     </properties>
 
     <dependencies>
+        <!-- 注意一定要引入对版本,要引入spring-cloud版本seata,而不是springboot版本的seata-->
+        <!--        1.如果你引入的是seata-all,请不要使用@EnableAutoDataSourceProxy注解。-->
+        <!--        2.如果你引入的是seata-spring-boot-starter 请关闭自动代理。-->
+        <!--        seata:enable-auto-data-source-proxy: false-->
         <dependency>
             <groupId>com.alibaba.cloud</groupId>
             <artifactId>spring-cloud-starter-alibaba-seata</artifactId>

+ 3 - 5
sckw-common/sckw-common-sentinel/src/main/java/com/sckw/sentinel/CustomBlockExceptionHandler.java

@@ -1,6 +1,6 @@
 package com.sckw.sentinel;
 
-/*
+
 import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.BlockExceptionHandler;
 import com.alibaba.csp.sentinel.slots.block.BlockException;
 import com.alibaba.csp.sentinel.slots.block.authority.AuthorityException;
@@ -16,7 +16,6 @@ import jakarta.servlet.http.HttpServletResponse;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.context.annotation.Configuration;
 
-*/
 /**
  * @author lfdc
  * @version 1.0
@@ -24,14 +23,14 @@ import org.springframework.context.annotation.Configuration;
  * @description 自定义sentinel异常Handler
  * @company sckw
  * @date 2023-06-08 09:06:59
- *//*
+ */
 
 @Slf4j
 @Configuration
 public class CustomBlockExceptionHandler implements BlockExceptionHandler {
     HttpResult httpResult = null;
     @Override
-    public void handle(HttpServletRequest httpServletRequest,HttpServletResponse httpServletResponse, BlockException e) throws Exception {
+    public void handle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, BlockException e) throws Exception {
         log.info("urlBlock.......................");
         //不同的异常返回不同的提示语
         //FlowException  //限流异常
@@ -102,4 +101,3 @@ public class CustomBlockExceptionHandler implements BlockExceptionHandler {
         new CustomBlockExceptionHandler();
     }
 }
-*/

+ 10 - 0
sckw-modules/sckw-example/pom.xml

@@ -58,6 +58,16 @@
             <artifactId>sckw-common-datasource</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>sckw-common-seata</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>sckw-common-sentinel</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>com.sckw</groupId>
             <artifactId>sckw-system-api</artifactId>

+ 1 - 0
sckw-modules/sckw-example/src/main/java/com/sckw/example/ExampleApplication.java

@@ -10,6 +10,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
 @EnableDubbo
 @EnableFeignClients({"com.sckw.*.api.feign"})
 @EnableDiscoveryClient
+//@EnableAutoDataSourceProxy
 @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
 public class ExampleApplication {
 

+ 5 - 1
sckw-modules/sckw-example/src/main/resources/bootstrap-dev.yml

@@ -61,7 +61,7 @@ spring:
       eager: true
   datasource:
     dynamic:
-      seata: false
+      seata: true
   main:
     allow-circular-references: true
 
@@ -90,6 +90,10 @@ seata:
       namespace: ${spring.cloud.nacos.discovery.namespace}
       group: ${spring.cloud.nacos.discovery.group}
   application-id: ${spring.application.name}
+  #  当前不生效,使用驼峰
+  enabled: true
+  #  enable-auto-data-source-proxy: false
+  enableAutoDataSourceProxy: false
 # 支持feign对sentinel支持
 #feign:
 #  sentinel:

+ 10 - 0
sckw-modules/sckw-file/pom.xml

@@ -48,6 +48,16 @@
             <artifactId>sckw-system-api</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>sckw-common-seata</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>sckw-common-sentinel</artifactId>
+        </dependency>
+
         <!--web-->
         <dependency>
             <groupId>org.springframework.boot</groupId>

+ 2 - 0
sckw-modules/sckw-file/src/main/java/com/sckw/file/FileApplication.java

@@ -1,5 +1,6 @@
 package com.sckw.file;
 
+import io.seata.spring.annotation.datasource.EnableAutoDataSourceProxy;
 import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -17,6 +18,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
 @EnableDubbo
 @EnableFeignClients({"com.sckw.*.api.feign"})
 @EnableDiscoveryClient
+@EnableAutoDataSourceProxy
 @SpringBootApplication
 public class FileApplication {
 

+ 16 - 5
sckw-modules/sckw-file/src/main/resources/bootstrap-dev.yml

@@ -5,7 +5,7 @@ spring:
         # 服务注册地址
         server-addr: 10.10.10.230:8848
         # 命名空间
-        namespace: sckw_zk
+        namespace: sckw-service-platform-dev
         # 共享配置
         group: sckw-service-platform
       config:
@@ -14,7 +14,7 @@ spring:
         # 配置文件格式
         file-extension: yaml
         # 命名空间
-        namespace: sckw_zk
+        namespace: sckw-service-platform-dev
         # 共享配置
         group: sckw-service-platform
 
@@ -61,7 +61,7 @@ spring:
       eager: true
   datasource:
     dynamic:
-      seata: false
+      seata: true
   main:
     allow-circular-references: true
 
@@ -72,7 +72,10 @@ seata:
   service:
     vgroup-mapping:
       # key是事务分组名称 value要和服务端的机房名称保持一致
-      system-seata-service-group: default
+      file-seata-service-group: default
+    #    配置与nacos同ip
+    grouplist:
+      default: 10.10.10.230
   registry:
     # 指定nacos作为注册中心
     type: nacos
@@ -89,11 +92,19 @@ seata:
       namespace: ${spring.cloud.nacos.discovery.namespace}
       group: ${spring.cloud.nacos.discovery.group}
   application-id: ${spring.application.name}
+  #  当前不生效,使用驼峰
+  enabled: true
+  #  enable-auto-data-source-proxy: false
+  enableAutoDataSourceProxy: false
 # 支持feign对sentinel支持
 #feign:
 #  sentinel:
 #    enabled: true
-
+  #限制上传文件大小
+  servlet:
+    multipart:
+      max-file-size: 100MB
+      max-request-size: 100MB
 # dubbo
 dubbo:
   application:

+ 10 - 0
sckw-modules/sckw-message/pom.xml

@@ -43,6 +43,16 @@
             <artifactId>sckw-common-stream</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>sckw-common-seata</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>sckw-common-sentinel</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>com.sckw</groupId>
             <artifactId>sckw-system-api</artifactId>

+ 2 - 0
sckw-modules/sckw-message/src/main/java/com/sckw/message/MessageApplication.java

@@ -1,5 +1,6 @@
 package com.sckw.message;
 
+import io.seata.spring.annotation.datasource.EnableAutoDataSourceProxy;
 import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -9,6 +10,7 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
 @EnableDubbo
 @EnableFeignClients({"com.sckw.*.api.feign"})
 @EnableDiscoveryClient
+@EnableAutoDataSourceProxy
 @SpringBootApplication
 public class MessageApplication {
 

+ 6 - 2
sckw-modules/sckw-message/src/main/resources/bootstrap-dev.yml

@@ -61,7 +61,7 @@ spring:
       eager: true
   datasource:
     dynamic:
-      seata: false
+      seata: true
   main:
     allow-circular-references: true
 
@@ -73,7 +73,7 @@ seata:
   service:
     vgroup-mapping:
       # key是事务分组名称 value要和服务端的机房名称保持一致
-      system-seata-service-group: default
+      message-seata-service-group: default
   registry:
     # 指定nacos作为注册中心
     type: nacos
@@ -90,6 +90,10 @@ seata:
       namespace: ${spring.cloud.nacos.discovery.namespace}
       group: ${spring.cloud.nacos.discovery.group}
   application-id: ${spring.application.name}
+  #  当前不生效,使用驼峰
+  enabled: true
+  #  enable-auto-data-source-proxy: false
+  enableAutoDataSourceProxy: false
 # 支持feign对sentinel支持
 #feign:
 #  sentinel:

+ 10 - 0
sckw-modules/sckw-system/pom.xml

@@ -43,6 +43,16 @@
             <artifactId>sckw-common-stream</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>sckw-common-seata</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.sckw</groupId>
+            <artifactId>sckw-common-sentinel</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>com.sckw</groupId>
             <artifactId>sckw-system-api</artifactId>

+ 4 - 0
sckw-modules/sckw-system/src/main/resources/bootstrap-dev.yml

@@ -89,6 +89,10 @@ seata:
       namespace: ${spring.cloud.nacos.discovery.namespace}
       group: ${spring.cloud.nacos.discovery.group}
   application-id: ${spring.application.name}
+  #  当前不生效,使用驼峰
+  enabled: true
+  #  enable-auto-data-source-proxy: false
+  enableAutoDataSourceProxy: false
 # 支持feign对sentinel支持
 #feign:
 #  sentinel: