Skip to content

Commit 9b803af

Browse files
committed
Polish "Document how to exclude an annotation processor with Maven"
See gh-22000
1 parent 627c0b1 commit 9b803af

File tree

2 files changed

+53
-32
lines changed

2 files changed

+53
-32
lines changed

spring-boot-project/spring-boot-docs/src/main/asciidoc/appendix-configuration-metadata.adoc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,30 @@ With Maven the dependency should be declared as optional, as shown in the follow
708708
</dependency>
709709
----
710710

711+
If you have defined `@ConfigurationProperties` in your application, make sure to configure the `spring-boot-maven-plugin` to prevent the `repackage` goal from adding the dependency into the fat jar:
712+
713+
[source,xml,indent=0,subs="verbatim,quotes,attributes"]
714+
----
715+
<project>
716+
<build>
717+
<plugins>
718+
<plugin>
719+
<groupId>org.springframework.boot</groupId>
720+
<artifactId>spring-boot-maven-plugin</artifactId>
721+
<configuration>
722+
<excludes>
723+
<exclude>
724+
<groupId>org.springframework.boot</groupId>
725+
<artifactId>spring-boot-configuration-processor</artifactId>
726+
</exclude>
727+
</excludes>
728+
</configuration>
729+
</plugin>
730+
</plugins>
731+
</build>
732+
</project>
733+
----
734+
711735
With Gradle 4.5 and earlier, the dependency should be declared in the `compileOnly` configuration, as shown in the following example:
712736

713737
[source,groovy,indent=0,subs="verbatim,quotes,attributes"]

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

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7583,42 +7583,39 @@ If you do it that way, the library is not provided and, by default, Spring Boot
75837583

75847584
Spring Boot uses an annotation processor to collect the conditions on auto-configurations in a metadata file (`META-INF/spring-autoconfigure-metadata.properties`).
75857585
If that file is present, it is used to eagerly filter auto-configurations that do not match, which will improve startup time.
7586-
It is recommended to add the following dependency in a module that contains auto-configurations and exclude it in the `spring-boot-maven-plugin` to prevent the repacking task from adding the dependency into the fat jar:
7586+
It is recommended to add the following dependency in a module that contains auto-configurations:
7587+
7588+
[source,xml,indent=0,subs="verbatim,quotes,attributes"]
7589+
----
7590+
<dependency>
7591+
<groupId>org.springframework.boot</groupId>
7592+
<artifactId>spring-boot-autoconfigure-processor</artifactId>
7593+
<optional>true</optional>
7594+
</dependency>
7595+
----
7596+
7597+
If you have defined auto-configurations directly in your application, make sure to configure the `spring-boot-maven-plugin` to prevent the `repackage` goal from adding the dependency into the fat jar:
75877598

75887599
[source,xml,indent=0,subs="verbatim,quotes,attributes"]
75897600
----
75907601
<project>
7591-
...
7592-
<dependencies>
7593-
<dependency>
7594-
<groupId>org.springframework.boot</groupId>
7595-
<artifactId>spring-boot-autoconfigure-processor</artifactId>
7596-
</dependency>
7597-
</dependencies>
7598-
<build>
7599-
...
7600-
<plugins>
7601-
...
7602-
<plugin>
7603-
<groupId>org.springframework.boot</groupId>
7604-
<artifactId>spring-boot-maven-plugin</artifactId>
7605-
<configuration>
7606-
<excludes>
7607-
...
7608-
<exclude>
7609-
<groupId>org.springframework.boot</groupId>
7610-
<artifactId>spring-boot-autoconfigure-processor</artifactId>
7611-
</exclude>
7612-
</excludes>
7613-
</configuration>
7614-
...
7615-
</plugin>
7616-
...
7617-
</plugins>
7618-
...
7619-
</build>
7620-
...
7621-
</project>
7602+
<build>
7603+
<plugins>
7604+
<plugin>
7605+
<groupId>org.springframework.boot</groupId>
7606+
<artifactId>spring-boot-maven-plugin</artifactId>
7607+
<configuration>
7608+
<excludes>
7609+
<exclude>
7610+
<groupId>org.springframework.boot</groupId>
7611+
<artifactId>spring-boot-autoconfigure-processor</artifactId>
7612+
</exclude>
7613+
</excludes>
7614+
</configuration>
7615+
</plugin>
7616+
</plugins>
7617+
</build>
7618+
</project>
76227619
----
76237620

76247621
With Gradle 4.5 and earlier, the dependency should be declared in the `compileOnly` configuration, as shown in the following example:

0 commit comments

Comments
 (0)