<dependency>
<groupId>io.shardingsphere</groupId>
<artifactId>sharding-jdbc-core</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>io.shardingsphere</groupId>
<artifactId>sharding-jdbc-spring-boot-starter</artifactId>
<version>3.1.0</version>
</dependency>
目录结构
server.port=8082
spring.profiles.active=sharding-tables
#spring.profiles.active=master-slave
mybatis.mapper-locations=classpath:mapping/*.xml
mybatis.type-aliases-package=com.lx.model
#pagehelper分页插件
pagehelper.helperDialect=mysql
pagehelper.reasonable=true
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql
sharding.jdbc.datasource.names=ds
sharding.jdbc.datasource.ds.type=com.alibaba.druid.pool.DruidDataSource
sharding.jdbc.datasource.ds.driver-class-name=com.mysql.jdbc.Driver
sharding.jdbc.datasource.ds.url=jdbc:mysql://127.0.0.1:3306/ds0
sharding.jdbc.datasource.ds.username=root
sharding.jdbc.datasource.ds.password=root
sharding.jdbc.config.sharding.tables.note.actual-data-nodes=ds.note$->{0..1}
sharding.jdbc.config.sharding.tables.note.table-strategy.inline.sharding-column=id
sharding.jdbc.config.sharding.tables.note.table-strategy.inline.algorithm-expression=note$->{id % 2}
sharding.jdbc.config.sharding.tables.note.key-generator-column-name=id