From 3a6d15acf657f9d5ff773d0c1a2ae551306fe665 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 12 Feb 2019 16:34:05 +0000 Subject: [PATCH] Caution against using component scanning in an auto-configuration Closes gh-15348 --- .../src/main/asciidoc/spring-boot-features.adoc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index ef17480954..4d3abe591c 100644 --- a/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -8072,6 +8072,14 @@ published jar. The file should list your configuration classes under the com.mycorp.libx.autoconfigure.LibXWebAutoConfiguration ---- +[NOTE] +==== +Auto-configurations must be loaded that way _only_. Make sure that they are defined in +a specific package space and that they are never the target of component scanning. +Futhermore, auto-configuration classes should not enable component scanning to find +additional components. Specific `@Import`s should be used instead. +==== + You can use the {sc-spring-boot-autoconfigure}/AutoConfigureAfter.{sc-ext}[`@AutoConfigureAfter`] or {sc-spring-boot-autoconfigure}/AutoConfigureBefore.{sc-ext}[`@AutoConfigureBefore`] @@ -8084,13 +8092,6 @@ knowledge of each other, you can also use `@AutoConfigureOrder`. That annotation same semantic as the regular `@Order` annotation but provides a dedicated order for auto-configuration classes. -[NOTE] -==== -Auto-configurations must be loaded that way _only_. Make sure that they are defined in -a specific package space and that, in particular, they are never the target of component -scanning. -==== - [[boot-features-condition-annotations]]