From e51dafd2d477223e7a7b7a2b46731062c33b27b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E8=8B=B1=E6=9D=B0?= <327782001@qq.com> Date: Sun, 19 Feb 2023 20:47:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=A7=A3=E5=86=B3=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../springbootkwan/service/impl/PersonServiceImpl.java | 3 ++- .../kwan/springbootkwan/service/impl/UserServiceImpl.java | 2 ++ src/main/resources/application.yaml | 7 ++++--- src/main/resources/file1111.conf | 5 +++++ 4 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 src/main/resources/file1111.conf 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 14defff..ea7cb7a 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 5ac8ba6..79ddf56 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 abae2ce..c03f88e 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 0000000..cfdc685 --- /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' +} -- GitLab