在使用到sharding-jdbc配置不分库的时候,遇到了报错:
我是这样配置的:
Failed to bind properties under 'spring.shardingsphere.sharding.tables.trole.database-strategy.none' to org.apache.shardingsphere.core.yaml.config.sharding.strategy.YamlNoneShardingStrategyConfiguration:
Property: spring.shardingsphere.sharding.tables.trole.database-strategy.none
Value:
Origin: class path resource [application-masterslave2.yml]:72:30
Reason: No converter found capable of converting from type [java.lang.String] to type [org.apache.shardingsphere.core.yaml.config.sharding.strategy.YamlNoneShardingStrategyConfiguration]
我发现none这个类没有其他属性,但是我这样配置就会一直报错,查看了网上的资料,有的大佬给出了解决办法,在none后面需要再加一层随便什么名字,就不会报错了
我们跟一下这个配置文件:
在yml配置文件中就可以通过prefix前缀:成员变量名:值 来配置
如果成员变量还是一个类,就再加一层来配置。prefix前缀:成员变量名:子类成员变量名:值
如果成员变量是一个类,而这个类却没有成员变量了,比如YamlNoneShardingStrategyConfiguration,那么仍然需要加一层。prefix前缀: 成员变量名:任意名 :值
如果你是properties文件,这样配置 :
spring.sharding.sharding.tables.t_role.database-strategy.none.any=