我把Sping Boot 从1.5.6升级到了2.0.0,开始出现了很多问题。一个是主题中给出的问题。我有一个带有属性的类
@Data
@ConfigurationProperties("eclipseLink")
public class EclipseLinkProperties { ... }
我在配置中使用
@Configuration
@EnableConfigurationProperties(EclipseLinkProperties.class)
public class WebDatasourceConfig { ... }
在编译过程中他把我扔了
2018-03-18 18:44:58.560 INFO 3528 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.context.properties.ConversionServiceDeducer$Factory' of type [org.springframework.boot.context.properties.ConversionServiceDeducer$Factory] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-03-18 18:44:58.575 WARN 3528 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'webDatasourceConfig': Unsatisfied dependency expressed through field 'eclipseLinkProperties'; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'eclipseLink-com.web.web.config.properties.EclipseLinkProperties': Could not bind properties to 'EclipseLinkProperties' : prefix=eclipseLink, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.source.InvalidConfigurationPropertyNameException: Configuration property name 'eclipseLink' is not valid
意思是
Configuration property name 'eclipseLink' is not valid
在Sping Boot 更新之前,一切正常。
5条答案
按热度按时间j13ufse21#
eclipseLink
不是有效的前缀。如文档中所述,应使用kebab-case而不是camelCase。因此,您的前缀应为eclipse-link
而不是eclipseLink
。31moq8wy2#
Sping Boot 2.0中不支持驼峰大小写。这将引发InvalidConfigurationPropertyNameException:配置属性名称“********”无效。
rsaldnfx3#
您可以变更:
至:
您不需要更改属性文件。这将避免错误。Spring将能够找到eclipseLink.* 属性。
xuo3flqw4#
当其中一个.yml文件中的新配置未添加到所有.yml文件(具体为test.yml)中时,会遇到此问题
wkyowqbh5#
在将Sping Boot 版本从1.5升级到2.5后遇到了同样的问题,此处支持kabab-case,您也可以更改为eclipse-link