我已经将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
It means
Configuration property name 'eclipseLink' is not valid
在 Spring Boot 更新之前一切正常。
eclipseLink
不是有效的前缀。作为文档中描述 https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-external-config-relaxed-binding应使用短横线命名法而不是驼峰命名法。所以你的前缀应该是eclipse-link
而不是eclipseLink
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)