Hello,
We were trying to migrate from 2.1.9 to 2.2.0 for our applications last week and encountered a startup failure due to a configuration validation failure. In short, if we are using @EnableConfigurationProperties combined with @ConditionalOnProperty for some beans, the new version is not respecting the conditional on the config part.
Here is a tiny example:
If we add this component to any Spring Boot application, it will fail to start with 2.2.0.
@Component
@ConditionalOnProperty(prefix = "foo", name = "enabled")
@EnableConfigurationProperties(FooBarConfig.class)
public class FooBar {
public FooBar() {
Logger.getGlobal().info("Starting FooBar...");
}
@ConfigurationProperties(prefix = "foo")
@Validated
static class FooBarConfig {
@NotNull
String bar;
public void setBar(String bar) {
this.bar = bar;
}
}
}
Expected behavior:
The bean initialization of FooBar and FooBarConfig should be skipped because @ConditionalOnProperty doesn't match.
Actual behavior:
FooBar is skipped but the FooBarConfig keeps initializing thus failed startup.