I have following block in application.yaml file:
foo:
bar: bazz
I want to map that configuration to a configuration class using @ConfigurationProperties.
@Validated
@Getter @Setter
@ConfigurationProperties(prefix = "foo")
public class FooProperties {
@NotNull
private String bar;
}
And here is configuration class
@Configuration
@EnableConfigurationProperties(FooProperties.class)
public class FooConfiguration {
@Bean
public Foo getFoo(FooProperties properties) {
///
}
}
However when I try to start application I get following error:
***************************
APPLICATION FAILED TO START
***************************
Description:
Binding to target org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'foo' to a.b.c.FooProperties failed:
Property: foo.bar
Value: null
Reason: must not be null
Action:
Update your application's configuration
Did I miss anything else? I cant figure out why such a trivial thing fails.