美文网首页
sharding-jdbc 雪花算法配置不生效问题

sharding-jdbc 雪花算法配置不生效问题

作者: 鹅鹅鹅_ | 来源:发表于2023-06-28 18:31 被阅读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

    相关文章

      网友评论

          本文标题:sharding-jdbc 雪花算法配置不生效问题

          本文链接:https://www.haomeiwen.com/subject/ehnoydtx.html