From d0b71a7d433e1b52108e8a478ca537840f3e7d3b Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 6 Jun 2018 10:37:57 +0200 Subject: [PATCH 1/2] Document usage of auto-configuration AP for 3rd party starters Closes gh-13368 --- .../main/asciidoc/spring-boot-features.adoc | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index 4c589334c0..bf445cc119 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -6490,6 +6490,30 @@ TIP: You should mark the dependencies to the library as optional so that you can the autoconfigure module in your projects more easily. If you do it that way, the library won't be provided and Spring Boot will back off by default. +Spring Boot uses an annotation processor to collect the conditions on auto-configurations +in a metadata file (`META-INF/spring-autoconfigure-metadata.json`). If that file is +present, it is used to eagerly filter auto-configurations that do not match, which will +improve startup time. It is recommended to add the following dependency in a module that +contains auto-configurations: + +[source,xml,indent=0,subs="verbatim,quotes,attributes"] +---- + + org.springframework.boot + spring-boot-autoconfigure-processor + true + +---- + +With Gradle you would add: + +[source,groovy,indent=0,subs="verbatim,quotes,attributes"] +---- + dependencies { + compileOnly "org.springframework.boot:spring-boot-autoconfigure-processor" + } +---- + [[boot-features-custom-starter-module-starter]] From 584d2de9f3f11912a2f585ec67bab2a7862be685 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Wed, 6 Jun 2018 10:53:55 +0200 Subject: [PATCH 2/2] Document use of component scan exclude filters on SpringBootApplication Closes gh-10933 --- .../src/main/asciidoc/spring-boot-features.adoc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index bf445cc119..59300cdf72 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -5421,13 +5421,21 @@ The search algorithm works up from the package that contains the test until it f <> in a sensible way your main configuration is usually found. -NOTE: If you use a +[NOTE] +==== +If you use a <> with such setup, you should avoid adding configuration that are specific to a particular area on the <>. +The underlying component scan configuration of `@SpringBootApplication` defines exclude +filters that are used to make sure slicing works as expected. If you are using an explicit +`@ComponentScan` directive on your `@SpringBootApplication`-annoted class, be aware that +those filters will be disabled. If you are using slicing, you should define them again. +==== + If you want to customize the primary configuration, you can use a nested `@TestConfiguration` class. Unlike a nested `@Configuration` class which would be used instead of a your application's primary configuration, a nested `@TestConfiguration` class