File tree Expand file tree Collapse file tree
modules/ROOT/pages/core/beans/java
spring-context/src/main/java/org/springframework/context/annotation Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ antora {
2020 ]
2121}
2222
23+ node {
24+ version = ' 24.15.0'
25+ }
26+
2327tasks. named(" generateAntoraYml" ) {
2428 asciidocAttributes = project. provider( {
2529 return [" spring-version" : project. version ]
Original file line number Diff line number Diff line change @@ -610,6 +610,19 @@ Kotlin::
610610See the {spring-framework-api}/context/annotation/Conditional.html[`@Conditional`]
611611javadoc for more detail.
612612
613+ [NOTE]
614+ ====
615+ A `@Conditional` annotation declared on an enclosing `@Configuration` class is only
616+ applied to the registration of a nested `@Configuration` class if the nested class is
617+ reached through the parser's recursion from its enclosing class, or via `@Import`. If a
618+ nested class is discovered independently of its enclosing class — for example, via
619+ `@ComponentScan` or by directly registering it against the application context — it is
620+ processed using only its own `@Conditional` annotations. Thus, if you wish to ensure that
621+ the same `@Conditional` annotations apply in such scenarios, you must redeclare the
622+ relevant annotations on the nested class, or extract them into a composed annotation
623+ which you apply to both the enclosing class and the nested class.
624+ ====
625+
613626
614627[[beans-java-combining]]
615628== Combining Java and XML Configuration
Original file line number Diff line number Diff line change 341341 * with the {@code @Profile} annotation to provide two options of the same bean to the
342342 * enclosing {@code @Configuration} class.
343343 *
344+ * <p>A {@link Conditional @Conditional} annotation declared on an enclosing
345+ * {@code @Configuration} class is only applied to the registration of a nested
346+ * {@code @Configuration} class if the nested class is reached through the parser's
347+ * recursion from its enclosing class, or via {@link Import @Import}. If a nested
348+ * class is discovered independently of its enclosing class — for example,
349+ * via {@link ComponentScan @ComponentScan} or by directly registering it against
350+ * the application context — it is processed using only its own
351+ * {@code @Conditional} annotations. Thus, if you wish to ensure that the same
352+ * {@code @Conditional} annotations apply in such scenarios, you must redeclare
353+ * the relevant annotations on the nested class, or extract them into a composed
354+ * annotation which you apply to both the enclosing class and the nested class.
355+ *
344356 * <h2>Configuring lazy initialization</h2>
345357 *
346358 * <p>By default, {@code @Bean} methods will be <em>eagerly instantiated</em> at container
You can’t perform that action at this time.
0 commit comments