shardingphere Sharding count cannot be null解决方案

编程入门 行业动态 更新时间:2024-10-26 10:36:38

shardingphere Sharding count cannot be null<a href=https://www.elefans.com/category/jswz/34/1770581.html style=解决方案"/>

shardingphere Sharding count cannot be null解决方案

shardingphere Sharding count cannot be null解决方案

  • 问题背景
  • 解决方案
  • Lyric: 我知道坚持要走

问题背景

使用shardingphere分表分库时,出现分表算法设置错误

Caused by: java.lang.IllegalArgumentException: Sharding count cannot be null.at com.googlemon.base.Preconditions.checkArgument(Preconditions.java:142)at org.apache.shardingsphere.sharding.algorithm.sharding.mod.ModShardingAlgorithm.getShardingCount(ModShardingAlgorithm.java:52)at org.apache.shardingsphere.sharding.algorithm.sharding.mod.ModShardingAlgorithm.init(ModShardingAlgorithm.java:48)at org.apache.shardingsphere.spring.boot.registry.AbstractAlgorithmProvidedBeanRegistry.postProcessAfterInitialization(AbstractAlgorithmProvidedBeanRegistry.java:98)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:431)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1800)at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595)... 200 common frames omitted
2023-11-03 13:48:14.179 INFO  [main][] c.a.d.p.DruidDataSource.init(DruidDataSource.java:998): {dataSource-2,master} inited
2023-11-03 13:48:14.179 INFO  [main][] c.b.d.d.DynamicRoutingDataSource.addDataSource(DynamicRoutingDataSource.java:148): dynamic-datasource - add a datasource named [sharding] success
2023-11-03 13:48:14.180 INFO  [main][] c.b.d.d.DynamicRoutingDataSource.addDataSource(DynamicRoutingDataSource.java:148): dynamic-datasource - add a datasource named [master] success
2023-11-03 13:48:14.180 INFO  [main][] c.b.d.d.DynamicRoutingDataSource.afterPropertiesSet(DynamicRoutingDataSource.java:228): dynamic-datasource initial loaded [2] datasource,primary datasource named [master]

解决方案

shardingphere5.1.1版本之前是不能使用下划线 _ 的,5.1.1版本可以使用下划线
如果使用5.0.0版本,就使用alg-mod

spring.shardingsphere.rules.sharding.sharding-algorithms.alg-mod.props.sharding-count=2048

如果使用5.1.1版本,可以使用alg_mod,也可以使用alg-mod

spring.shardingsphere.rules.sharding.sharding-algorithms.alg_mod.props.sharding-count=2048




作为程序员第 249 篇文章,每次写一句歌词记录一下,看看人生有几首歌的时间,wahahaha …

Lyric: 我知道坚持要走

更多推荐

shardingphere Sharding count cannot be null解决方案

本文发布于:2023-11-16 22:28:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634524.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:解决方案   Sharding   shardingphere   null   count

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!