博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
sharding-jdbc不分库策略在springboot的application.properties中的写法
阅读量:7084 次
发布时间:2019-06-28

本文共 1724 字,大约阅读时间需要 5 分钟。

sharding-jdbc不分片策略NoneShardingStrategy在springboot中的写法

使用springboot的application.properties来定义分片策略时,

sharding.jdbc.config.sharding.default-database-strategy.none=

这样写会报错

***************************APPLICATION FAILED TO START***************************Description:Binding to target io.shardingjdbc.spring.boot.sharding.SpringBootShardingRuleConfigurationProperties@675ffd1d failed:    Property: sharding.jdbc.config.sharding.defaultDatabaseStrategy.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 'defaultDatabaseStrategy.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-database-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 {
}

转载地址:http://opmml.baihongyu.com/

你可能感兴趣的文章
ZooKeerper学习之Watcher
查看>>
【转】每天一个linux命令(14):head 命令
查看>>
Careerdesign@foxmail.com
查看>>
mkdir failed for img Read-only file system
查看>>
写在2015年即将来临之际
查看>>
【UVA】434-Matty's Blocks
查看>>
MyISAM和InnoDB的区别
查看>>
boost.lexical_cast 学习
查看>>
Android中使用第三方jar包
查看>>
JS问题Uncaught ReferenceError:XXXX is not defined
查看>>
android之【本地通知Notification】
查看>>
应用程序框架实战三十:表现层及ASP.NET MVC介绍(一)
查看>>
Android之drawable state各个属性详解
查看>>
【.NET特供-第三季】ASP.NET MVC系列:MVC与三层图形对照
查看>>
平衡二叉树
查看>>
采用FPGA实现多种类型的数字信号处理滤波器
查看>>
浅谈android4.0开发之GridLayout布局
查看>>
CloseHandle(),TerminateThread(),ExitThread()的差别
查看>>
后端码农谈前端(HTML篇)第三课:常见属性
查看>>
NPOI系列
查看>>