You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

52 lines
2.0 KiB

spring.application.name=www
server.port=8081
#1800s
server.servlet.session.timeout=1800
spring.jackson.time-zone=GMT+8
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
#定义数据源
spring.shardingsphere.datasource.names=m1,m2
spring.shardingsphere.datasource.m1.url=jdbc:mysql://127.0.0.1:3306/test?serverTimezone=GMT%2b8&useUnicode=true&characterEncoding=utf8
spring.shardingsphere.datasource.m1.username=root
spring.shardingsphere.datasource.m1.password=123456
spring.shardingsphere.datasource.m1.driver‐class‐name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.m1.type=com.alibaba.druid.pool.DruidDataSource
spring.shardingsphere.datasource.m2.url=jdbc:mysql://127.0.0.1:3306/test2?serverTimezone=GMT%2b8&useUnicode=true&characterEncoding=utf8
spring.shardingsphere.datasource.m2.username=root
spring.shardingsphere.datasource.m2.password=123456
spring.shardingsphere.datasource.m2.driver‐class‐name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.m2.type=com.alibaba.druid.pool.DruidDataSource
# 指定t_user表的数据分布情况,配置数据节点
spring.shardingsphere.sharding.tables.t_user.actual‐data‐nodes=m$->{1..2}.t_user_$->{1..2}
# 指定t_user表的主键生成策略为SNOWFLAKE
spring.shardingsphere.sharding.tables.t_user.key‐generator.column=id
spring.shardingsphere.sharding.tables.t_user.key‐generator.type=SNOWFLAKE
# 指定t_user表的分库策略,分库策略包括分片键和分片算法
spring.shardingsphere.sharding.tables.t_user.database-strategy.inline.sharding‐column=sex
spring.shardingsphere.sharding.tables.t_user.database-strategy.inline.algorithm‐expression=m$->{sex % 2 + 1}
# 指定t_user表的分表策略,分表策略包括分片键和分片算法
spring.shardingsphere.sharding.tables.t_user.table‐strategy.inline.sharding‐column=id
spring.shardingsphere.sharding.tables.t_user.table‐strategy.inline.algorithm‐expression=t_user_$->{id % 2 + 1}
# 控制台日志配置
logging.level.root=info
# 打开sql输出日志
spring.shardingsphere.props.sql.show=true
#mapper文件扫描路径
mybatis.mapper-locations=classpath:/mapper/*.xml