springboot 配置文件
spring.shardingsphere.datasource.names=db0,db1
# 数据源 db0 配置
spring.shardingsphere.datasource.db0.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.db0.driver-class-name=com.mysql.cj.jdbc.Driver
# 注意 这里不是以前的url
spring.shardingsphere.datasource.db0.jdbc-url=jdbc:mysql://192.168.139.101:3306/test?characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2b8
spring.shardingsphere.datasource.db0.username=da
spring.shardingsphere.datasource.db0.password=dashan007@
# 数据源 db1 配置
spring.shardingsphere.datasource.db1.type=com.zaxxer.hikari.HikariDataSource
spring.shardingsphere.datasource.db1.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.db1.jdbc-url=jdbc:mysql://192.168.139.103:3306/test?characterEncoding=utf-8&useSSL=false&serverTimezone=GMT%2b8
spring.shardingsphere.datasource.db1.username=da
spring.shardingsphere.datasource.db1.password=dashan007@
# 真实数据节点表达式
spring.shardingsphere.sharding.tables.t_order.actual-data-nodes=db$->{0..1}.t_order_$->{0..1}
# 分库策略
spring.shardingsphere.sharding.tables.t_order.database-strategy.inline.sharding-column=spu_id
spring.shardingsphere.sharding.tables.t_order.database-strategy.inline.algorithm-expression=db$->{spu_id % 2}
# 分表策略
spring.shardingsphere.sharding.tables.t_order.table-strategy.inline.sharding-column=id
spring.shardingsphere.sharding.tables.t_order.table-strategy.inline.algorithm-expression=t_order_$->{id % 2}
# 广播表 / 全局表
spring.shardingsphere.sharding.broadcast-tables=area
mybatis.mapper-locations=classpath:/mappers/*.xml
logging.pattern.dateformat=HH:mm:ss
spring:
shardingsphere: