版本坐标

druid-spring-boot-starter.version:1.1.10
spring-cloud-alibaba.version:2.2.10-RC1
spring-cloud.version:Hoxton.SR12
spring-boot.version:2.3.12.RELEASE
dynamic.datasource.version:3.6.1
mybatis-plus.version:3.5.3
dubbo.version:3.1.7
seata.version:1.6.1
db-->postgresql.version: 14.5
jdk:1.8
<dependency>
        <groupId>io.seata</groupId>
        <artifactId>seata-spring-boot-starter</artifactId>
        <version>1.6.1</version>
        <exclusions>
            <exclusion>
                <groupId>com.alibaba</groupId>
                <artifactId>druid</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.alibaba.cloud</groupId>
        <artifactId>spring-cloud-starter-alibaba-seata</artifactId>
        <exclusions>
            <exclusion>
                <groupId>io.seata</groupId>
                <artifactId>seata-spring-boot-starter</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependency>

现象:

使用注解@GlobalTransactional 就会抛异常,无法插入数据

若使用@transactional 则不会抛异常,正常插入数据

解决思路:

  1. 排查自己的postgresql依赖版本

推荐使用

<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>postgresql</artifactId>
    <version>42.3.3</version>
</dependency>
  1. 升级druid依赖

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>druid-spring-boot-starter</artifactId>
    <version>1.2.16</version>
</dependency>

issues地址: https://github.com/seata/seata/issues/5451

解决该问题后出现异常[ShouldNeverHappenException: pkIndex is not found]

该问题相关issues地址: https://github.com/seata/seata/issues/5264

有兴趣的同学可以参考修改下源码:https://github.com/seata/seata/pull/5294/commits/868b438f7fa5c9b1d5bec794c49072a7728f67af

综合考虑后放弃使用seata

Logo

鸿蒙生态一站式服务平台。

更多推荐