SpringBoot+Mybayis+ShardingJDBC實現分庫分表,動態切換數據庫

 摘自:https://blog.csdn.net/mianyao1004/article/details/104662018/

 

 

這幾天一直在搞分庫分表,由於使用場景特殊,一直搞不定,記錄一下,sharding官方文檔特別全,其實這個文檔就夠了。

ShardingSphere官網:https://shardingsphere.apache.org/document/current/cn/overview/

配置說明:https://shardingsphere.apache.org/document/current/cn/manual/sharding-jdbc/configuration/

官網配置:https://shardingsphere.apache.org/document/current/cn/manual/sharding-jdbc/configuration/config-spring-boot/

GitHub地址:https://github.com/apache/incubator-shardingsphere

官方實例:https://github.com/geomonlin/incubator-shardingsphere-example

ShardingJDBC的幾個例子:

https://www.liangzl.com/get-article-detail-163740.html

https://www.jianshu.com/p/3b2ab87b0de7

注意點:

1.分表規則需要配置tableRuleConfigs,而tableRuleConfigs需要配置分庫規則,一定要配置分庫規則,一定要!一定要!

2.一個數據源分庫分表,另一個沒有,貌似需要配置mybatis,不然有問題。

3.看官方文檔真的夠了!!!別把時間浪費在其他博客上。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章