Skip to content

Commit 3a6d15a

Browse files
committed
Caution against using component scanning in an auto-configuration
Closes gh-15348
1 parent 8e6b462 commit 3a6d15a

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8072,6 +8072,14 @@ published jar. The file should list your configuration classes under the
80728072
com.mycorp.libx.autoconfigure.LibXWebAutoConfiguration
80738073
----
80748074

8075+
[NOTE]
8076+
====
8077+
Auto-configurations must be loaded that way _only_. Make sure that they are defined in
8078+
a specific package space and that they are never the target of component scanning.
8079+
Futhermore, auto-configuration classes should not enable component scanning to find
8080+
additional components. Specific `@Import`s should be used instead.
8081+
====
8082+
80758083
You can use the
80768084
{sc-spring-boot-autoconfigure}/AutoConfigureAfter.{sc-ext}[`@AutoConfigureAfter`] or
80778085
{sc-spring-boot-autoconfigure}/AutoConfigureBefore.{sc-ext}[`@AutoConfigureBefore`]
@@ -8084,13 +8092,6 @@ knowledge of each other, you can also use `@AutoConfigureOrder`. That annotation
80848092
same semantic as the regular `@Order` annotation but provides a dedicated order for
80858093
auto-configuration classes.
80868094

8087-
[NOTE]
8088-
====
8089-
Auto-configurations must be loaded that way _only_. Make sure that they are defined in
8090-
a specific package space and that, in particular, they are never the target of component
8091-
scanning.
8092-
====
8093-
80948095

80958096

80968097
[[boot-features-condition-annotations]]

0 commit comments

Comments
 (0)