web-dev-qa-db-ja.com

プロパティをバインドできませんでした

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アップデートの前は、すべてが機能していました。

9
rytyrtytr

eclipseLinkは有効な接頭辞ではありません。 ドキュメントに記載されています キャメルケースではなくケバブケースを使用する必要があります。したがって、プレフィックスはeclipseLinkではなくEclipse-linkにする必要があります。

16
Andy Wilkinson

キャメルケースはSpring boot 2.0ではサポートされていません。 InvalidConfigurationPropertyNameExceptionがスローされます。構成プロパティ名 '********'は無効です。

1
Debadatta