sharding-jdbc 雪花算法配置不生效问题
2023-06-28 本文已影响0人
鹅鹅鹅_
凭借多年经验的直觉,解决了,直接说原因。
无效的配置:
spring.shardingsphere.sharding.tables.simads_tbl.actual-data-nodes=sharding-mcc.simads_tbl_$->{2023..2025}0$->{1..9},sharding-mcc.simads_tbl_$->{2021..2025}$->{10..11}
spring.shardingsphere.sharding.tables.simads_tbl.table-strategy.standard.sharding-column=id
spring.shardingsphere.sharding.tables.simads_tbl.table-strategy.standard.precise-algorithm-class-name=com.ankeyproject.config.sharding.TimeShardingAlgorithm
spring.shardingsphere.sharding.tables.simads_tbl.table-strategy.standard.range-algorithm-class-name=com.ankeyproject.config.sharding.TimeShardingAlgorithm
spring.shardingsphere.sharding.tables.simads_tbl.key-generator.column=id
spring.shardingsphere.sharding.tables.simads_tbl.key-generator.type=snowflake
有效的配置
#雪花算法配置放在其他配置前面,否则不生效
spring.shardingsphere.sharding.tables.simads_tbl.key-generator.column=id
spring.shardingsphere.sharding.tables.simads_tbl.key-generator.type=snowflake
spring.shardingsphere.sharding.tables.simads_tbl.actual-data-nodes=sharding-mcc.simads_tbl_$->{2023..2025}0$->{1..9},sharding-mcc.simads_tbl_$->{2021..2025}$->{10..11}
spring.shardingsphere.sharding.tables.simads_tbl.table-strategy.standard.sharding-column=id
spring.shardingsphere.sharding.tables.simads_tbl.table-strategy.standard.precise-algorithm-class-name=com.ankeyproject.config.sharding.TimeShardingAlgorithm
spring.shardingsphere.sharding.tables.simads_tbl.table-strategy.standard.range-algorithm-class-name=com.ankeyproject.config.sharding.TimeShardingAlgorithm
还有一点需要注意的就是如果涉及到vo bo等,都需要加上主键id