# Springboot-ReadWrite-demo **Repository Path**: tree3170/Springboot-ReadWrite-demo ## Basic Information - **Project Name**: Springboot-ReadWrite-demo - **Description**: Springboot多种方式实现读写分离 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2019-06-02 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Spring Boot 读写分离 ## 1. 模块rw-demo1 ``` 利用Spring提供的路由数据源AbstractRoutingDataSource来路由所配置的所有数据源,具体查看MyRoutingDataSource 利用AOP设定的规则,比如说在Mapper上定义了Master annotation的方法路由到master,其余路由到slave,查看DatasourceAop ``` ### 参考: [SpringBoot+MyBatis+MySQL读写分离](https://www.cnblogs.com/cjsblog/p/9712457.html) [MySQL多数据源笔记2-Spring多数据源一主多从读写分离(手写)](https://www.cnblogs.com/huangjuncong/p/8576935.html) [SpringBoot2.0.3+Mybatis+Mysql+druid实现读写分离+事务+切换数据源失败](https://blog.csdn.net/mameng1988/article/details/83338786) ## 2. ShareJdbc 实践读写分离 主要包括如下2点: ``` 1. 第一个是ShardingMasterSlaveConfig,用于注册所有的数据源(datasources)和注册Sharding的规则配置(shardingRuleConfiguration) 2. 第二个类是ShardingDataSourceConfig, Sharding data source factory, 用于创建sharding的数据源 ```