diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionalOnProperty.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionalOnProperty.java index 3189ef15ff..45e4cd48ff 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionalOnProperty.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionalOnProperty.java @@ -22,6 +22,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.springframework.boot.autoconfigure.couchbase.OnBootstrapHostsCondition; import org.springframework.context.annotation.Conditional; import org.springframework.core.env.Environment; @@ -72,6 +73,20 @@ import org.springframework.core.env.Environment; * {@link #matchIfMissing()} attribute is consulted. By default missing attributes do not * match. * + *
+ * This condition cannot be reliably used for matching collection properties. For example, + * in the following configuration, the condition matches if {@code spring.example.values} + * is present in the {@link Environment} but does not match if {@code spring.example.values[0]} is present. + * + *
+ * @ConditionalOnProperty(prefix = "spring", name = "example.values") + * class ExampleAutoConfiguration { + * } + *+ * + * It is better to use a custom condition for such cases. + * See {@link OnBootstrapHostsCondition} for an example of a custom condition. + * * @author Maciej Walkowiak * @author Stephane Nicoll * @author Phillip Webb