sharding-jdbc不分片策略NoneShardingStrategy在springboot中的写法
使用springboot的application.properties来定义分片策略时,
sharding.jdbc.config.sharding.default-data -strategy.none=这样写会报错
***************************APPLICATION FAILED TO START***************************De ion:Binding to target io.shardingjdbc.spring.boot.sharding.SpringBootShardingRuleConfigurationProperties@675ffd1d failed: Property: sharding.jdbc.config.sharding.defaultData Strategy.none Value: Reason: Failed to convert property value of type 'java.lang.String' to required type 'io.shardingjdbc.core.yaml.sharding.strategy.YamlNoneShardingStrategyConfiguration' for property 'defaultData Strategy.none'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'io.shardingjdbc.core.yaml.sharding.strategy.YamlNoneShardingStrategyConfiguration' for property 'none': no matching editors or conversion strategy foundAction:Update your application's configuration需要写成
sharding.jdbc.config.sharding.default-data -strategy.none.any=即,在none后面再加一层随便什么名字。
因为springboot中,使用了@ConfigurationProperties的类,在properties文件中就可以通过 “prefix前缀 . 成员变量名 = 值” 来配置。
如果成员变量还是一个类,就再加一层来配置。即“prefix前缀 . 成员变量名 . 子类成员变量名 = 值”。
特殊的, 如果成员变量是一个类,而它却没有成员变量了(例如amlNoneShardingStrategyConfiguration),那么仍然需要加一层。即“prefix前缀 . 成员变量名 . 任意名 = 值”。
// SpringBootShardingRuleConfigurationProperties.java@ConfigurationProperties(prefix = "sharding.jdbc.config.sharding")public class SpringBootShardingRuleConfigurationProperties extends YamlShardingRuleConfiguration {}// YamlNoneShardingStrategyConfiguration.javapublic final class YamlNoneShardingStrategyConfiguration implements YamlShardingStrategyConfiguration {} 继续阅读与本文标签相同的文章
-
tf.contrib.seq2seq.sequence_loss example:seqence loss 实例代码
2026-05-26栏目: 教程
-
FaceBook 发布星际争霸最大 AI 数据集
2026-05-26栏目: 教程
-
tf.contrib.legacy_seq2seq.basic_rnn_seq2seq 函数 example 最简单实现
2026-05-26栏目: 教程
-
Keras 多层感知机 多类别的 softmax 分类模型代码
2026-05-26栏目: 教程
-
开始 Keras 序列模型(Sequential model)
2026-05-26栏目: 教程
