You might be interested in the abstract class AllNestedConditions , which was introduced in Spring Boot 1.3.0. This allows you to create complex conditions when all the conditions that you define must be applied before any @Bean is initialized by your @Configuration class.
public class ThisPropertyAndThatProperty extends AllNestedConditions { @ConditionalOnProperty("this.property") @Bean public ThisPropertyBean thisProperty() { } @ConditionalOnProperty("that.property") @Bean public ThatPropertyBean thatProperty() { } }
Then you can annotate your @Configuration as follows:
@Conditional({ThisPropertyAndThatProperty.class} @Configuration
source share