RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
spring+shardingjdbc+Atomikos分布式事务配置是什么

本篇文章给大家分享的是有关spring+shardingjdbc+Atomikos分布式事务配置是什么,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。

创新互联公司是一家专业提供和顺企业网站建设,专注与成都网站建设、成都做网站、成都h5网站建设、小程序制作等业务。10年已为和顺众多企业、政府机构等服务。创新互联专业网站制作公司优惠进行中。

分表和其他表在一个库里,满足分布式事务,

pom配置:

    org.apache.shardingsphere    sharding-jdbc-spring-namespace    4.0.0-RC1    org.apache.shardingsphere    sharding-jdbc-core    4.0.0-RC1    org.apache.shardingsphere    sharding-transaction-xa-core    4.0.0-RC1

数据源配置:

                                jdbc:mysql://${jdbc.host}/${jdbc.database}            ${jdbc.username}            ${jdbc.password}                                            
                                    

分别为两个数据源配上sqlSessionFactory和MapperScannerConfigurer(为了省事只配了一个)

                        

分布式事务配置:

                

分表策略:

public final class TableShardingAlgorithm implements PreciseShardingAlgorithm {    @Override    public String doSharding(final Collection availableTargetNames, final PreciseShardingValue shardingValue) {for (String each : availableTargetNames) {if (each.endsWith(shardingValue.getValue() % 2 + "")) {return each;            }
        }throw new UnsupportedOperationException();    }
}

以上就是spring+shardingjdbc+Atomikos分布式事务配置是什么,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注创新互联行业资讯频道。


新闻名称:spring+shardingjdbc+Atomikos分布式事务配置是什么
标题URL:http://scyingshan.cn/article/jpiiip.html