integrationTest設定でgradle(3.4.1)を使用すると、アプリケーションが正しく初期化されてもSpringブート(1.5.1.RELEASE)のConfigurationPropertiesを使用したテストが失敗します./gradlew bootRun)。 ConfigurationPropertiesで注釈が付けられたクラスは、次のようになります。統合テスト用にSpringブート設定プロパティを初期化できません
@Component
@ConfigurationProperties(prefix = "foo")
@Validated
public class AppConfiguration {
@NonNull
private URL serviceUrl;
...
設定ファイルには、ゲッターとセッターがあります。次のように生成されたエラーは、統合テストの構成クラスが注釈され
java.lang.IllegalStateException: Failed to load ApplicationContext
....
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'AppConfiguration': Could not bind properties to AppConfiguration
....
Caused by: org.springframework.validation.BindException: org.springframework.boot.bind.RelaxedDataBinder$RelaxedBeanPropertyBindingResult
Field error in object 'foo' on field 'serviceUrl': rejected value [null]; codes ...
次のような
@Configuration
@ComponentScan(...)
@EnableConfigurationProperties
@EnableIntegration
public static class ContextConfiguration {}