1.windows配置seata
可以点击Tags切换版本
下载后解压,完需要修改的两个部分:
1.修改conf文件夹下的file.conf,将mode改为你需要的存储方式,如我这里改成了redis
2.修改注册的方式,修改register.conf文件的type属性为nacos
并将nacos选项配置为自己的信息
3.下载config.txt文件,此文件存储的是seate的详细配置
下载config.txt
将config.txt文件放在项目目录下:
4.下载nacos-config.sh文件
下载nacos-config.sh
5.打开git bash
执行:
sh nacos-config.sh -h localhost -p 8848 -g SEATA_GROUP -t 9eeffe66-d561-4b00-a42c-38d13fd5cd09 -u nacos -w nacos
set nacosAddr=localhost:8848
set group=SEATA_GROUP
多了的几个都是seata的配置
以上说明设置成功
2.启动seata-server
运行bin目录下的seata-server.bat
如下说明启动成功:
查看nacos中的服务
可以看到seata-server已经注册到了nacos服务列表中
3.SpringCloud Alibaba整合seata
引入依赖
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-seata</artifactId>
</dependency>
yml配置:
seata:
enabled: true
enable-auto-data-source-proxy: true
tx-service-group: my_test_tx_group
registry:
type: nacos
nacos:
application: seata-server
server-addr: 127.0.0.1:8848
username: nacos
password: nacos
config:
type: nacos
nacos:
server-addr: 127.0.0.1:8848
group: SEATA_GROUP
username: nacos
password: nacos
namespace: 9eeffe66-d561-4b00-a42c-38d13fd5cd09
service:
vgroup-mapping:
my_test_tx_group: default
disable-global-transaction: false
client:
rm:
report-success-enable: false
使用:主事务上添加@GlobalTransactional注解