shardingShpere 分布式事务(1)

微服务绕不开分布式事务。本章展示简单分布式案例。

背景:使用spring boot 1.5.17.RELEASE + shardingsphere 5.0.0-alpha + bitronix + druid 1.2.4 + mysql8

 

1. mysql 用户需要具备相应权限(允许执行 XA RECOVER语句),这里为用户分配所有权限

GRANT ALL ON *.* TO 'root'@'%' 

参考(https://blog.csdn.net/mxskymx/article/details/88765072

2. pom.xml

 

<properties>
        <shardingsphere.version>5.0.0-alpha</shardingsphere.version>
        <spring.boot.version>1.5.17.RELEASE</spring.boot.version>
        <commons-dbcp2.version>2.2.0</commons-dbcp2.version>
        <commons-pool.version>1.6</commons-pool.version>
        <druid.version>1.2.4</druid.version>
        <hutool.version>5.0.7</hutool.version>
        <mybatis-plus.version>3.4.1</mybatis-plus.version>
        <mysql.connector.version>8.0.17</mysql.connector.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>chuck-spring-cloud-common-entity</groupId>
            <artifactId>chuck-spring-cloud-common-entity</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>chuck-spring-cloud-comm-util</groupId>
            <artifactId>chuck-spring-cloud-comm-util</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>

        <dependency>
            <groupId>org.apache.shardingsphere</groupId>
            <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
            <version>${shardingsphere.version}</version>
        </dependency>

        <!-- sql 解析 -->
        <dependency>
            <groupId>org.apache.shardingsphere</groupId>
            <artifactId>shardingsphere-sql-parser-mysql</artifactId>
            <version>${shardingsphere.version}</version>
        </dependency>

        <!-- 使用XA 事务时,需要引⼊此模块 -->
        <dependency>
            <groupId>org.apache.shardingsphere</groupId>
            <artifactId>shardingsphere-transaction-xa-core</artifactId>
            <version>${shardingsphere.version}</version>
        </dependency>

        <!-- 使用BASE事务时,需要引入此模块 <dependency> <groupId>org.apache.shardingsphere</groupId> 
            <artifactId>shardingsphere-transaction-base-seata-at</artifactId> <version>${shardingsphere.version}</version> 
            </dependency> -->
            
            <dependency>
            <groupId>org.apache.shardingsphere</groupId>
            <artifactId>shardingsphere-transaction-xa-bitronix</artifactId>
            <version>${shardingsphere.version}</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.btm</groupId>
            <artifactId>btm</artifa

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值