sharding-jdbc 5.2.1启动报错

方便更快捷的说明问题,可以按需填写(可删除)

使用环境:

依赖:

org.apache.shardingsphere
shardingsphere-jdbc-core-spring-boot-starter
5.2.1

yaml配置:
spring:
shardingsphere:
enabled: true
# 是否开启
datasource:
names: ds0
ds0:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
username: root
password: root
url: jdbc:mysql://mysql-server:3307/emwd?useSSL=false&serverTimezone=Asia/Shanghai&characterEncoding=utf-8&autoReconnect=true
# 分片的配置
rules:
sharding:
default-data-source-name: ds0
props:
#是否输出sql
sql-show: true
binding-tables[0]: P_USER
# 表的分片策略
tables:
# 逻辑表的名称
P_USER: # 水平分表
actual-data-nodes: ds0.P_USER,ds0.$->{com.yfhx.modules.sharding.ShardingAlgorithmTool.getActualDataNodes(“P_USER”)} # 分库分表分表表达式
table-strategy:
standard:
# 配置分片字段
sharding-column: create_date
# 分片算法名字
sharding-algorithm-name: create_Date
sharding-algorithms: # 分片算法配置
create_Date:
type: CLASS_BASED
props:
strategy: STANDARD
algorithmClassName: com.yfhx.modules.sharding.DateShardingAlgorithm

场景、问题:

项目启动时报错:
Caused by: java.lang.NullPointerException: Properties strategy can not be null when uses class based sharding strategy.
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:864)
at org.apache.shardingsphere.sharding.algorithm.sharding.classbased.ClassBasedShardingAlgorithm.getStrategy(ClassBasedShardingAlgorithm.java:66)
at org.apache.shardingsphere.sharding.algorithm.sharding.classbased.ClassBasedShardingAlgorithm.init(ClassBasedShardingAlgorithm.java:59)
at org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPIRegistry.findRegisteredService(TypedSPIRegistry.java:66)
at org.apache.shardingsphere.infra.util.spi.type.typed.TypedSPIRegistry.getRegisteredService(TypedSPIRegistry.java:113)

已进行操作:

ClassBasedShardingAlgorithm中getStrategy方法进入两次,第一次正常,第二次为空

现状:

解决了吗?同样的问题

京ICP备2021015875号