File tree Expand file tree Collapse file tree
framework-docs/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 @@ -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` declared on an enclosing `@Configuration` class gates the
616+ registration of nested `@Configuration` classes within it only when the
617+ nested class is reached through the parser's recursion from its enclosing
618+ class, or through `@Import`. When the nested class is discovered
619+ independently of its enclosing class, for example via `@ComponentScan` or
620+ by directly registering it against the application context, it is processed
621+ using only its own `@Conditional` annotations. In that case, redeclare the
622+ relevant conditions on the nested class, or extract them into a composed
623+ annotation applied to both, if the same gating is intended.
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>{@link Conditional @Conditional} annotations declared on an enclosing
345+ * {@code @Configuration} class gate registration of any nested
346+ * {@code @Configuration} classes within it when the nested class is reached
347+ * through the parser's recursion from its enclosing class (the case shown
348+ * above) or via {@link Import @Import}. When the nested class is discovered
349+ * independently of its enclosing class, for example via
350+ * {@link ComponentScan @ComponentScan} or by directly registering the nested
351+ * class against the application context, it is processed using only its own
352+ * {@code @Conditional} annotations. In that case, redeclare the relevant
353+ * conditions on the nested class, or extract them into a composed
354+ * annotation applied to both, if the same gating is intended.
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