Spring Boot version: 3.3.0 - Question The class has the following two fields. SpringBoot Does the annotation @ConditionalOnProperty have a problem ? The "name" is an array, but the "havingValue" is a single value. If I want to check two field and its value, how the "havingValue" works ? Is this a problem ?

Comment From: bclozel

This design came from both #812 and #1000 and I believe this is intentional. If we were to have both String[] name and String[] havingValue, all conditions would need to match for all possible key/value combination. In practice, this wouldn't work.

@ConditionalOnProperty(name={"prop.first", "prop.second"}, havingValue={"spring", "boot"})

Would expect prop.first=spring AND prop.second=spring AND prop.first=boot AND prop.second=boot. This would never match, would it?

For more complex conditions, you can always annotated your auto-configuration class with @Conditional(YourCustomCondition.class) and implement your custom condition accordingly. We're doing so in many places in Spring Boot.

For further questions, please use StackOverflow.

Comment From: tswstarplanet

This design came from both #812 and #1000 and I believe this is intentional. If we were to have both String[] name and String[] havingValue, all conditions would need to match for all possible key/value combination. In practice, this wouldn't work.

@ConditionalOnProperty(name={"prop.first", "prop.second"}, havingValue={"spring", "boot"})

Would expect prop.first=spring AND prop.second=spring AND prop.first=boot AND prop.second=boot. This would never match, would it?

For more complex conditions, you can always annotated your auto-configuration class with @Conditional(YourCustomCondition.class) and implement your custom condition accordingly. We're doing so in many places in Spring Boot.

For further questions, please use StackOverflow.

Why not use the order to indicate the mapping between elements of “name” and “having Value”? For your example, just check prop.first = spring and prop.second = boot

Comment From: philwebb

I'd find that confusing and I don't think we want to introduce any more complexity here. I think we're happy with the design as it is. Use AllNestedConditions if you want to compose conditions.