diff --git a/zlt-demo/seata-demo/README.md b/zlt-demo/seata-demo/README.md
index 34205968..c90b4e0a 100644
--- a/zlt-demo/seata-demo/README.md
+++ b/zlt-demo/seata-demo/README.md
@@ -1,11 +1,70 @@
## **详细的原理和部署细节请查看**
[Spring Cloud同步场景分布式事务怎样做?试试Seata](https://mp.weixin.qq.com/s/0yCmHzlXDC9BkbUuEt0_fQ)
+
+## 测试环境
+* mysql 5.7
+* seata 1.3
+* nacos 1.3
+> **注意**:如果nacos使用低于1.3的版本不需要配置username和password;如果使用1.3以上版本必需开启 `nacos.core.auth.enabled=true` 并且配置username和password,否则读取不到seata-server
+
+## 配置中心的配置如下
+**config.txt**
+```properties
+service.vgroupMapping.test_tx_service_group=default
+store.mode=db
+store.db.datasource=druid
+store.db.dbType=mysql
+store.db.url=jdbc:mysql://192.168.28.130:3306/seata?useUnicode=true
+store.db.driverClassName=com.mysql.jdbc.Driver
+store.db.user=root
+store.db.password=root
+store.db.minConn=5
+store.db.maxConn=30
+store.db.globalTable=global_table
+store.db.branchTable=branch_table
+store.db.queryLimit=100
+store.db.lockTable=lock_table
+store.db.maxWait=5000
+```
+>根据自己的环境修改 url、user、password 配置值
+
+## seata的配置如下
+**registry.conf**
+```json
+registry {
+ # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
+ type = "nacos"
+
+ nacos {
+ application = "seata-server"
+ serverAddr = "192.168.28.130:8848"
+ group = "SEATA_GROUP"
+ namespace = ""
+ cluster = "default"
+ username = "nacos"
+ password = "nacos"
+ }
+}
+
+config {
+ # file、nacos 、apollo、zk、consul、etcd3
+ type = "nacos"
+
+ nacos {
+ serverAddr = "192.168.28.130:8848"
+ namespace = ""
+ group = "SEATA_GROUP"
+ username = "nacos"
+ password = "nacos"
+ }
+}
+```
+
+
## 说明
-
-
**包括以下5个模块,分别是**
* `business-service`:业务服务
diff --git a/zlt-demo/seata-demo/account-service/src/main/resources/application.yml b/zlt-demo/seata-demo/account-service/src/main/resources/application.yml
index 9e1eaef2..1f7f5a96 100644
--- a/zlt-demo/seata-demo/account-service/src/main/resources/application.yml
+++ b/zlt-demo/seata-demo/account-service/src/main/resources/application.yml
@@ -4,8 +4,20 @@ spring:
username: root
password: 1q2w3e4r
driver-class-name: com.mysql.cj.jdbc.Driver
- cloud:
- alibaba:
- seata:
- # seata 服务分组,要与服务端nacos-config.txt中service.vgroup_mapping的后缀对应,默认是${spring.application.name}-fescar-service-group
- tx-service-group: account-service-group
\ No newline at end of file
+
+seata:
+ tx-service-group: test_tx_service_group
+ config:
+ type: nacos
+ nacos:
+ serverAddr: ${spring.cloud.nacos.server-addr}
+ group: SEATA_GROUP
+ username: nacos
+ password: nacos
+ registry:
+ type: nacos
+ nacos:
+ server-addr: ${spring.cloud.nacos.server-addr}
+ group: SEATA_GROUP
+ username: nacos
+ password: nacos
\ No newline at end of file
diff --git a/zlt-demo/seata-demo/account-service/src/main/resources/bootstrap.yml b/zlt-demo/seata-demo/account-service/src/main/resources/bootstrap.yml
index fce0c942..1c062281 100644
--- a/zlt-demo/seata-demo/account-service/src/main/resources/bootstrap.yml
+++ b/zlt-demo/seata-demo/account-service/src/main/resources/bootstrap.yml
@@ -4,7 +4,10 @@ server:
spring:
application:
name: account-service
+ main:
+ allow-bean-definition-overriding: true
cloud:
nacos:
- discovery:
- server-addr: 192.168.28.130:8848
\ No newline at end of file
+ server-addr: 192.168.28.130:8848
+ username: nacos
+ password: nacos
\ No newline at end of file
diff --git a/zlt-demo/seata-demo/account-service/src/main/resources/registry.conf b/zlt-demo/seata-demo/account-service/src/main/resources/registry.conf
deleted file mode 100644
index 96c107da..00000000
--- a/zlt-demo/seata-demo/account-service/src/main/resources/registry.conf
+++ /dev/null
@@ -1,26 +0,0 @@
-registry {
- # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
- type = "nacos"
-
- nacos {
- serverAddr = "192.168.28.130"
- namespace = "public"
- cluster = "default"
- }
- file {
- name = "file.conf"
- }
-}
-config {
- # file、nacos 、apollo、zk、consul、etcd3
- type = "nacos"
- nacos {
- serverAddr = "192.168.28.130"
- namespace = "public"
- cluster = "default"
- }
- file {
- name = "file.conf"
- }
-}
-
diff --git a/zlt-demo/seata-demo/business-service/src/main/resources/application.yml b/zlt-demo/seata-demo/business-service/src/main/resources/application.yml
index 6c197a08..8fbb3389 100644
--- a/zlt-demo/seata-demo/business-service/src/main/resources/application.yml
+++ b/zlt-demo/seata-demo/business-service/src/main/resources/application.yml
@@ -1,6 +1,16 @@
-spring:
- cloud:
- alibaba:
- seata:
- # seata 服务分组,要与服务端nacos-config.txt中service.vgroup_mapping的后缀对应,默认是${spring.application.name}-fescar-service-group
- tx-service-group: business-service-group
\ No newline at end of file
+seata:
+ tx-service-group: test_tx_service_group
+ config:
+ type: nacos
+ nacos:
+ serverAddr: ${spring.cloud.nacos.server-addr}
+ group: SEATA_GROUP
+ username: nacos
+ password: nacos
+ registry:
+ type: nacos
+ nacos:
+ server-addr: ${spring.cloud.nacos.server-addr}
+ group: SEATA_GROUP
+ username: nacos
+ password: nacos
\ No newline at end of file
diff --git a/zlt-demo/seata-demo/business-service/src/main/resources/bootstrap.yml b/zlt-demo/seata-demo/business-service/src/main/resources/bootstrap.yml
index 8196da7a..722d9145 100644
--- a/zlt-demo/seata-demo/business-service/src/main/resources/bootstrap.yml
+++ b/zlt-demo/seata-demo/business-service/src/main/resources/bootstrap.yml
@@ -4,7 +4,15 @@ server:
spring:
application:
name: business-service
+ main:
+ allow-bean-definition-overriding: true
cloud:
nacos:
- discovery:
- server-addr: 192.168.28.130:8848
\ No newline at end of file
+ server-addr: 192.168.28.130:8848
+ username: nacos
+ password: nacos
+
+ribbon:
+ ConnectTimeout: 100000
+ ReadTimeout: 1000000
+ OkToRetryOnAllOperations: false
\ No newline at end of file
diff --git a/zlt-demo/seata-demo/business-service/src/main/resources/registry.conf b/zlt-demo/seata-demo/business-service/src/main/resources/registry.conf
deleted file mode 100644
index 96c107da..00000000
--- a/zlt-demo/seata-demo/business-service/src/main/resources/registry.conf
+++ /dev/null
@@ -1,26 +0,0 @@
-registry {
- # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
- type = "nacos"
-
- nacos {
- serverAddr = "192.168.28.130"
- namespace = "public"
- cluster = "default"
- }
- file {
- name = "file.conf"
- }
-}
-config {
- # file、nacos 、apollo、zk、consul、etcd3
- type = "nacos"
- nacos {
- serverAddr = "192.168.28.130"
- namespace = "public"
- cluster = "default"
- }
- file {
- name = "file.conf"
- }
-}
-
diff --git a/zlt-demo/seata-demo/order-service/src/main/resources/application.yml b/zlt-demo/seata-demo/order-service/src/main/resources/application.yml
index 857eb806..1f7f5a96 100644
--- a/zlt-demo/seata-demo/order-service/src/main/resources/application.yml
+++ b/zlt-demo/seata-demo/order-service/src/main/resources/application.yml
@@ -4,8 +4,20 @@ spring:
username: root
password: 1q2w3e4r
driver-class-name: com.mysql.cj.jdbc.Driver
- cloud:
- alibaba:
- seata:
- # seata 服务分组,要与服务端nacos-config.txt中service.vgroup_mapping的后缀对应,默认是${spring.application.name}-fescar-service-group
- tx-service-group: order-service-group
\ No newline at end of file
+
+seata:
+ tx-service-group: test_tx_service_group
+ config:
+ type: nacos
+ nacos:
+ serverAddr: ${spring.cloud.nacos.server-addr}
+ group: SEATA_GROUP
+ username: nacos
+ password: nacos
+ registry:
+ type: nacos
+ nacos:
+ server-addr: ${spring.cloud.nacos.server-addr}
+ group: SEATA_GROUP
+ username: nacos
+ password: nacos
\ No newline at end of file
diff --git a/zlt-demo/seata-demo/order-service/src/main/resources/bootstrap.yml b/zlt-demo/seata-demo/order-service/src/main/resources/bootstrap.yml
index a4fe7107..13799e00 100644
--- a/zlt-demo/seata-demo/order-service/src/main/resources/bootstrap.yml
+++ b/zlt-demo/seata-demo/order-service/src/main/resources/bootstrap.yml
@@ -4,7 +4,10 @@ server:
spring:
application:
name: order-service
+ main:
+ allow-bean-definition-overriding: true
cloud:
nacos:
- discovery:
- server-addr: 192.168.28.130:8848
\ No newline at end of file
+ server-addr: 192.168.28.130:8848
+ username: nacos
+ password: nacos
\ No newline at end of file
diff --git a/zlt-demo/seata-demo/order-service/src/main/resources/registry.conf b/zlt-demo/seata-demo/order-service/src/main/resources/registry.conf
deleted file mode 100644
index 96c107da..00000000
--- a/zlt-demo/seata-demo/order-service/src/main/resources/registry.conf
+++ /dev/null
@@ -1,26 +0,0 @@
-registry {
- # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
- type = "nacos"
-
- nacos {
- serverAddr = "192.168.28.130"
- namespace = "public"
- cluster = "default"
- }
- file {
- name = "file.conf"
- }
-}
-config {
- # file、nacos 、apollo、zk、consul、etcd3
- type = "nacos"
- nacos {
- serverAddr = "192.168.28.130"
- namespace = "public"
- cluster = "default"
- }
- file {
- name = "file.conf"
- }
-}
-
diff --git a/zlt-demo/seata-demo/pom.xml b/zlt-demo/seata-demo/pom.xml
index b4497cdc..61036ffb 100644
--- a/zlt-demo/seata-demo/pom.xml
+++ b/zlt-demo/seata-demo/pom.xml
@@ -9,6 +9,17 @@
seata-demo
seata分布式事务demo
pom
+
+
+
+
+ io.seata
+ seata-spring-boot-starter
+ 1.3.0
+
+
+
+
business-service
diff --git a/zlt-demo/seata-demo/storage-service/src/main/resources/application.yml b/zlt-demo/seata-demo/storage-service/src/main/resources/application.yml
index ec287685..1f7f5a96 100644
--- a/zlt-demo/seata-demo/storage-service/src/main/resources/application.yml
+++ b/zlt-demo/seata-demo/storage-service/src/main/resources/application.yml
@@ -4,8 +4,20 @@ spring:
username: root
password: 1q2w3e4r
driver-class-name: com.mysql.cj.jdbc.Driver
- cloud:
- alibaba:
- seata:
- # seata 服务分组,要与服务端nacos-config.txt中service.vgroup_mapping的后缀对应,默认是${spring.application.name}-fescar-service-group
- tx-service-group: storage-service-group
\ No newline at end of file
+
+seata:
+ tx-service-group: test_tx_service_group
+ config:
+ type: nacos
+ nacos:
+ serverAddr: ${spring.cloud.nacos.server-addr}
+ group: SEATA_GROUP
+ username: nacos
+ password: nacos
+ registry:
+ type: nacos
+ nacos:
+ server-addr: ${spring.cloud.nacos.server-addr}
+ group: SEATA_GROUP
+ username: nacos
+ password: nacos
\ No newline at end of file
diff --git a/zlt-demo/seata-demo/storage-service/src/main/resources/bootstrap.yml b/zlt-demo/seata-demo/storage-service/src/main/resources/bootstrap.yml
index 5de51a8c..d1db4cde 100644
--- a/zlt-demo/seata-demo/storage-service/src/main/resources/bootstrap.yml
+++ b/zlt-demo/seata-demo/storage-service/src/main/resources/bootstrap.yml
@@ -4,7 +4,10 @@ server:
spring:
application:
name: storage-service
+ main:
+ allow-bean-definition-overriding: true
cloud:
nacos:
- discovery:
- server-addr: 192.168.28.130:8848
\ No newline at end of file
+ server-addr: 192.168.28.130:8848
+ username: nacos
+ password: nacos
\ No newline at end of file
diff --git a/zlt-demo/seata-demo/storage-service/src/main/resources/registry.conf b/zlt-demo/seata-demo/storage-service/src/main/resources/registry.conf
deleted file mode 100644
index 96c107da..00000000
--- a/zlt-demo/seata-demo/storage-service/src/main/resources/registry.conf
+++ /dev/null
@@ -1,26 +0,0 @@
-registry {
- # file 、nacos 、eureka、redis、zk、consul、etcd3、sofa
- type = "nacos"
-
- nacos {
- serverAddr = "192.168.28.130"
- namespace = "public"
- cluster = "default"
- }
- file {
- name = "file.conf"
- }
-}
-config {
- # file、nacos 、apollo、zk、consul、etcd3
- type = "nacos"
- nacos {
- serverAddr = "192.168.28.130"
- namespace = "public"
- cluster = "default"
- }
- file {
- name = "file.conf"
- }
-}
-