diff --git a/src/main/java/com/kwan/springbootkwan/service/impl/PersonServiceImpl.java b/src/main/java/com/kwan/springbootkwan/service/impl/PersonServiceImpl.java index 14defff0e5086e3a3949e10af352ef864e2c2147..ea7cb7a5234259eb84e0e3185a1b0453569759a7 100644 --- a/src/main/java/com/kwan/springbootkwan/service/impl/PersonServiceImpl.java +++ b/src/main/java/com/kwan/springbootkwan/service/impl/PersonServiceImpl.java @@ -13,10 +13,11 @@ public class PersonServiceImpl extends ServiceImpl impleme @Autowired private PersonMapper personMapper; -// @DS(value ="ali-ds" ) + // @DS(value ="ali-ds" ) @Override public Person savePerson(Person person) { personMapper.insert(person); + final int i = 1 / 0; return person; } } diff --git a/src/main/java/com/kwan/springbootkwan/service/impl/UserServiceImpl.java b/src/main/java/com/kwan/springbootkwan/service/impl/UserServiceImpl.java index 5ac8ba651a4aa3763e1981f0c7c0878b774c2077..79ddf56abce134d834fc23eafbe16d1391ab7a83 100644 --- a/src/main/java/com/kwan/springbootkwan/service/impl/UserServiceImpl.java +++ b/src/main/java/com/kwan/springbootkwan/service/impl/UserServiceImpl.java @@ -6,6 +6,7 @@ import com.kwan.springbootkwan.entity.User; import com.kwan.springbootkwan.mapper.UserMapper; import com.kwan.springbootkwan.service.IPersonService; import com.kwan.springbootkwan.service.IUserService; +import io.seata.spring.annotation.GlobalTransactional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -39,6 +40,7 @@ public class UserServiceImpl extends ServiceImpl implements IU return userByName; } + @GlobalTransactional @Override public User saveUser(User user) { userMapper.insert(user); diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index abae2ce144438875d03a3a7b153437df018e213f..c03f88e7597e141b9e0d62b0056d0ca4e8eaca44 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -57,12 +57,13 @@ spring: seata: application-id: spring-boot-name - tx-service-group: spring-boot-name-group + tx-service-group: my-tx-group service: vgroup-mapping: - spring-boot-demo-group: default + my-tx-group: seata-server grouplist: - default: 127.0.0.1:8091 + seata-server: 127.0.0.1:8091 + enabled: true diff --git a/src/main/resources/file1111.conf b/src/main/resources/file1111.conf new file mode 100644 index 0000000000000000000000000000000000000000..cfdc6857c4eca9fb1dc8021d705b22be95ace5f9 --- /dev/null +++ b/src/main/resources/file1111.conf @@ -0,0 +1,5 @@ +service { +#事务组名称 + vgroup_mapping.my-tx-group ="seata-server" + default.grouplist ="127.0.0.1:8091' +}