You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Caused by: org.springframework.validation.BindException: org.springframework.boot.bind.RelaxedDataBinder$RelaxedBeanPropertyBindingResult: 1 errors
Field error in object 'spring.datasource.druid' on field 'url': rejected value [jdbc:mysql://XXXXXX]; codes [methodInvocation.spring.datasource.druid.url,methodInvocation.url,methodInvocation.java.lang.String,methodInvocation]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [spring.datasource.druid.url,url]; arguments []; default message [url]]; default message [Property 'url' threw exception; nested exception is java.lang.UnsupportedOperationException]
at org.springframework.boot.bind.PropertiesConfigurationFactory.checkForBindingErrors(PropertiesConfigurationFactory.java:359)
at org.springframework.boot.bind.PropertiesConfigurationFactory.doBindPropertiesToTarget(PropertiesConfigurationFactory.java:276)
at org.springframework.boot.bind.PropertiesConfigurationFactory.bindPropertiesToTarget(PropertiesConfigurationFactory.java:240)
at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.postProcessBeforeInitialization(ConfigurationPropertiesBindingPostProcessor.java:330)
... 27 more
The text was updated successfully, but these errors were encountered:
环境版本:
复现方法
前提
配置多数据源: spring.datasource.druid.*的默认配置与spring.datasource.druid.XXX.*的配置不一致,并且是使用下面ConfigurationProperties的配置方式来配置时
触发原因
当该DataSource已经初始化一次之后,如果Spring再次触发EnvironmentChangeEvent事件,会导致使用所有标注了@ConfigurationProperties的DruidDataSourceWrapper重新做参数绑定。这个时候,根据spring的规则,会先绑定DruidDataSourceWrapper对象class上标注的@ConfigurationProperties,而这个参数和factory方法上绑定的参数不一致,这时候就会触发DruidDataSource内对已经inited之后修改属性值抛出的UnsupportOperationException
异常示例
The text was updated successfully, but these errors were encountered: