无法绑定属性

时间:2018-03-18 17:51:45

标签: java spring spring-mvc spring-boot eclipselink

我已经将Spring 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

在Spring Boot更新之前,一切正常。

4 个答案:

答案 0 :(得分:11)

eclipseLink不是有效的前缀。应该使用described in the documentation烤肉串而不是camelCase。因此,您的前缀应为eclipse-link,而不是eclipseLink

答案 1 :(得分:0)

Spring boot 2.0不支持Camel案例。它会抛出InvalidConfigurationPropertyNameException:配置属性名称'********'无效。

答案 2 :(得分:0)

当未在所有.yml文件(未指定test.yml)中添加.yml文件之一中的新配置时解决了此问题

答案 3 :(得分:0)

您可以更改:

@ConfigurationProperties("eclipseLink")

到:

@ConfigurationProperties("eclipselink")

您不需要更改属性文件。这将避免错误。 Spring 将能够找到 eclipseLink.* 属性。

相关问题