diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionalOnExpression.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionalOnExpression.java index bdef69f3b7..a8c4782a5b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionalOnExpression.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionalOnExpression.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2019 the original author or authors. + * Copyright 2012-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,6 +27,11 @@ import org.springframework.context.annotation.Conditional; /** * Configuration annotation for a conditional element that depends on the value of a SpEL * expression. + *

+ * Referencing a bean in the expression will cause that bean to be initialized very early + * in context refresh processing. As a result, the bean won't be eligible for + * post-processing (such as configuration properties binding) and its state may be + * incomplete. * * @author Dave Syer * @since 1.0.0 diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/developing-auto-configuration.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/developing-auto-configuration.adoc index df245f4ee0..afd1f457f2 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/developing-auto-configuration.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/developing-auto-configuration.adoc @@ -143,6 +143,9 @@ This condition will not match for applications that are run with an embedded ser ==== SpEL Expression Conditions The `@ConditionalOnExpression` annotation lets configuration be included based on the result of a {spring-framework-docs}/core.html#expressions[SpEL expression]. +NOTE: Referencing a bean in the expression will cause that bean to be initialized very early in context refresh processing. +As a result, the bean won't be eligible for post-processing (such as configuration properties binding) and its state may be incomplete. + [[features.developing-auto-configuration.testing]]