If you want all properties to have the same value:
@ConditionalOnProperty(value = {"random.property.one", "random.property.two"}, havingValue = "true", matchIfMissing = false)
@Bean
public ConditionalyCreatedBean conditionallyCreateadBean() {
return new ConditionalyCreatedBean();
}
Maybe more flexible:
@ConditionalOnExpression("#{${random.property.one} and ${random.property.two}")
Note: Compile-time vs Runtime Evaluation
@ConditionalOnProperty: Evaluated early during Spring's configuration processing, before CGLIB enhancement
@ConditionalOnExpression: Evaluated later during bean creation, after CGLIB has already tried to enhance the configuration class