I have a bean wiring up a 3rd-party class as a @ConfigurationProperties
bean, but Spring never populates the values.
the code looks something like:
The bean binding:
@Bean
@ConfigurationProperties(prefix = "aws")
@ConditionalOnMissingBean(AwsServiceConfigurationProperties.class)
public AwsServiceConfigurationProperties defaultServiceProperties() {
return new AwsServiceConfigurationProperties();
}
the bean type:
@Data
public class AwsServiceConfigurationProperties {
private URI endpoint;
private Region region;
}
and my test trying to validate it's working:
@Test
void shouldPickUpProperties() {
contextRunner
.withPropertyValues("aws.endpoint=http://fake-aws.test", "aws.region=test")
.run(ctx -> assertThat(ctx.getBean(AwsServiceConfigurationProperties.class))
.isNotNull()
.hasAllNullFieldsOrPropertiesExcept("endpoint")
.hasFieldOrPropertyWithValue("endpoint", URI.create("http://fake-aws.test"))
);
}
everything i can find in the docs and examples say it should be working with this setup, but the fields are all always null
.