mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Polish "Add a note on early init with @ConditionalOnExpression"
See gh-29276
This commit is contained in:
parent
fce3cd1684
commit
5fe6176966
@ -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.
|
||||
* <p>
|
||||
* 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
|
||||
@ -40,10 +45,6 @@ public @interface ConditionalOnExpression {
|
||||
/**
|
||||
* The SpEL expression to evaluate. Expression should return {@code true} if the
|
||||
* condition passes or {@code false} if it fails.
|
||||
* <p>
|
||||
* 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 will load with
|
||||
* default property values.
|
||||
* @return the SpEL expression
|
||||
*/
|
||||
String value() default "true";
|
||||
|
@ -143,7 +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 will load with default property values.
|
||||
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]]
|
||||
|
Loading…
Reference in New Issue
Block a user