Document `@ConditionalOnProperty` limitation with collections

Closes gh-7483
pull/14003/head
Madhura Bhave 6 years ago
parent 57515dfa78
commit 6bd438a737

@ -22,6 +22,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import org.springframework.boot.autoconfigure.couchbase.OnBootstrapHostsCondition;
import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Conditional;
import org.springframework.core.env.Environment; 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 * {@link #matchIfMissing()} attribute is consulted. By default missing attributes do not
* match. * match.
* *
* <p>
* 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.
*
* <pre class="code">
* &#064;ConditionalOnProperty(prefix = "spring", name = "example.values")
* class ExampleAutoConfiguration {
* }
* </pre>
*
* 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 Maciej Walkowiak
* @author Stephane Nicoll * @author Stephane Nicoll
* @author Phillip Webb * @author Phillip Webb

Loading…
Cancel
Save