ToYaml.com
实测非常好用!
spring.main.allow-bean-definition-overriding=true
spring.shardingsphere.datasource.m0.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.m0.password=
spring.shardingsphere.datasource.m0.type=com.alibaba.druid.pool.DruidDataSource
spring.shardingsphere.datasource.m0.url=jdbc:mysql://url/sharding_db0?setUnicode=true&characterEncoding=utf8&useSSL=false
spring.shardingsphere.datasource.m0.username=root
spring.shardingsphere.datasource.m1.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.m1.password=
spring.shardingsphere.datasource.m1.type=com.alibaba.druid.pool.DruidDataSource
spring.shardingsphere.datasource.m1.url=jdbc:mysql://url/sharding_db1?setUnicode=true&characterEncoding=utf8&useSSL=false
spring.shardingsphere.datasource.m1.username=root
spring.shardingsphere.datasource.names=m0,m1,s0,s1
spring.shardingsphere.datasource.s0.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.s0.password=
spring.shardingsphere.datasource.s0.type=com.alibaba.druid.pool.DruidDataSource
spring.shardingsphere.datasource.s0.url=jdbc:mysql://url/sharding_db0?setUnicode=true&characterEncoding=utf8&useSSL=false
spring.shardingsphere.datasource.s0.username=root
spring.shardingsphere.datasource.s1.driver-class-name=com.mysql.cj.jdbc.Driver
spring.shardingsphere.datasource.s1.password=
spring.shardingsphere.datasource.s1.type=com.alibaba.druid.pool.DruidDataSource
spring.shardingsphere.datasource.s1.url=jdbc:mysql://url/sharding_db1?setUnicode=true&characterEncoding=utf8&useSSL=false
spring.shardingsphere.datasource.s1.username=root
spring.shardingsphere.props.sql.show=true
spring.shardingsphere.sharding.binding-tables=course
spring.shardingsphere.sharding.default-database-strategy.inline.algorithm-expression=ds$->{user_id % 2}
spring.shardingsphere.sharding.default-database-strategy.inline.sharding-column=user_id
spring.shardingsphere.sharding.master-slave-rules.ds0.master-data-source-name=m0
spring.shardingsphere.sharding.master-slave-rules.ds0.slave-data-source-names=s0
spring.shardingsphere.sharding.master-slave-rules.ds1.master-data-source-name=m1
spring.shardingsphere.sharding.master-slave-rules.ds1.slave-data-source-names=s1
spring.shardingsphere.sharding.tables.course.actual-data-nodes=ds$->{0..1}.course_$->{1..2}
spring.shardingsphere.sharding.tables.course.key-generator.column=cid
spring.shardingsphere.sharding.tables.course.key-generator.type=SNOWFLAKE
spring.shardingsphere.sharding.tables.course.table-strategy.inline.algorithm-expression=course_$->{cid % 2 + 1}
spring.shardingsphere.sharding.tables.course.table-strategy.inline.sharding-column=cid
spring:
main:
allow-bean-definition-overriding: true
shardingsphere:
datasource:
m0:
driver-class-name: com.mysql.cj.jdbc.Driver
password: ''
type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://url/sharding_db0?setUnicode=true&characterEncoding=utf8&useSSL=false
username: root
m1:
driver-class-name: com.mysql.cj.jdbc.Driver
password: ''
type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://url/sharding_db1?setUnicode=true&characterEncoding=utf8&useSSL=false
username: root
names: m0,m1,s0,s1
s0:
driver-class-name: com.mysql.cj.jdbc.Driver
password: ''
type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://url/sharding_db0?setUnicode=true&characterEncoding=utf8&useSSL=false
username: root
s1:
driver-class-name: com.mysql.cj.jdbc.Driver
password: ''
type: com.alibaba.druid.pool.DruidDataSource
url: jdbc:mysql://url/sharding_db1?setUnicode=true&characterEncoding=utf8&useSSL=false
username: root
props:
sql:
show: true
sharding:
binding-tables: course
default-database-strategy:
inline:
algorithm-expression: ds$->{user_id % 2}
sharding-column: user_id
master-slave-rules:
ds0:
master-data-source-name: m0
slave-data-source-names: s0
ds1:
master-data-source-name: m1
slave-data-source-names: s1
tables:
course:
actual-data-nodes: ds$->{0..1}.course_$->{1..2}
key-generator:
column: cid
type: SNOWFLAKE
table-strategy:
inline:
algorithm-expression: course_$->{cid % 2 + 1}
sharding-column: cid