首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法绑定属性

无法绑定属性
EN

Stack Overflow用户
提问于 2018-03-18 17:51:44
回答 5查看 19.8K关注 0票数 18

我已经将Spring从1.5.6版本更新到了2.0.0,并且出现了很多问题。其中之一是题目中的问题。我有一个有属性的类

代码语言:javascript
复制
@Data
@ConfigurationProperties("eclipseLink")
public class EclipseLinkProperties { ... }

我在配置中使用的

代码语言:javascript
复制
@Configuration
@EnableConfigurationProperties(EclipseLinkProperties.class)
public class WebDatasourceConfig { ... }

在编译过程中,他抛弃了我

代码语言:javascript
复制
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

这意味着

代码语言:javascript
复制
Configuration property name 'eclipseLink' is not valid

在Spring更新之前,一切都成功了。

EN

回答 5

Stack Overflow用户

回答已采纳

发布于 2018-03-18 18:02:05

eclipseLink不是有效的前缀。作为在文档中描述,烤箱应该被使用而不是camelCase。所以你的前缀应该是eclipse-link而不是eclipseLink

票数 34
EN

Stack Overflow用户

发布于 2018-04-12 10:25:25

Spring 2.0不支持Camel情况。它将引发InvalidConfigurationPropertyNameException:配置属性名称‘*’无效。

票数 3
EN

Stack Overflow用户

发布于 2021-07-21 22:25:14

你可以改变:

代码语言:javascript
复制
@ConfigurationProperties("eclipseLink")

至:

代码语言:javascript
复制
@ConfigurationProperties("eclipselink")

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

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49351104

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档