Skip to content

Commit bd1e7e1

Browse files
committed
Merge branch '7.0.x'
2 parents 25e8395 + c17939e commit bd1e7e1

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

framework-docs/framework-docs.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ antora {
2020
]
2121
}
2222

23+
node {
24+
version = '24.15.0'
25+
}
26+
2327
tasks.named("generateAntoraYml") {
2428
asciidocAttributes = project.provider( {
2529
return ["spring-version": project.version ]

framework-docs/modules/ROOT/pages/core/beans/java/composing-configuration-classes.adoc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,19 @@ Kotlin::
610610
See the {spring-framework-api}/context/annotation/Conditional.html[`@Conditional`]
611611
javadoc 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

spring-context/src/main/java/org/springframework/context/annotation/Configuration.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,18 @@
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 &mdash; for example,
349+
* via {@link ComponentScan @ComponentScan} or by directly registering it against
350+
* the application context &mdash; 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

0 commit comments

Comments
 (0)