一、springboot2.X整合的是
<dependency>
<groupId>io.shardingjdbc</groupId>
<artifactId>sharding-jdbc-core</artifactId>
<version>2.0.3</version>
</dependency>
二、使用haspmap创建多分库多数据源时,需要注意map对应的额key需要与数据库名称同
private Map<String, DataSource> createDataSourceMap() {
Map<String, DataSource> result = new HashMap<>();
result.put("realpay_test_0", dataSource0());
result.put("realpay_test_1", dataSource1());
return result;
}
项目地址:
https://github.com/qq1272692827/spring-boot1.X-sharding-jdbc-.git
一个讲的不错的博客