seata整合springcloud
导入依赖
<dependency>
<groupId>io.seata</groupId>
<artifactId>seata-spring-boot-starter</artifactId>
<version>1.3.0</version>
</dependency>
单机版
seata:
config:
type: file #配置中心类型
registry:
type: file #注册中心类型
application-id: server-seata #应用id
service:
vgroup-mapping:
springboot-seata-group: default
grouplist:
default: 127.0.0.1:8091
tx-service-group: springboot-seata-group
方法上打上注解
@GlobalTransactional//seata全局事务注解
@DS("slave_1")
@Override
public void selectBYMaster() {
user byId = this.getById(1);
System.out.println("slave_1");
System.out.println(byId.getUserName());
}