I need to check that two conditions are satisfied on a YAML property file, while creating a bean. How do I do that, as the @ConditionalOnProperty
annotation supports only one property?
Since from the beginning of @ConditionalOnProperty
it was possible to check more than one property. The name / value attribute is an array.
@Configuration
@ConditionalOnProperty({ "property1", "property2" })
protected static class MultiplePropertiesRequiredConfiguration {
@Bean
public String foo() {
return "foo";
}
}
For simple boolean properties with an AND check you don't need a @ConditionalOnExpression
.