forked from spring-projects/spring-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clarify conditional support when using AOT
Closes spring-projectsgh-35262
- Loading branch information
1 parent
cd48252
commit 8a14f6d
Showing
3 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/aot.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
[[howto.aot]] | ||
== Ahead-of-time processing | ||
|
||
A number of questions often arise when people use the ahead-of-time processing of Spring Boot applications. | ||
This section addresses those questions. | ||
|
||
[[howto.aot.conditions]] | ||
=== Conditions | ||
|
||
Ahead-of-time processing optimizes the application and evaluates {spring-framework-api}/context/annotation/Conditional.html[conditions] based on the environment at build time. | ||
<<features#features.profiles,Profiles>> are implemented through conditions and are therefore affected, too. | ||
|
||
If you want beans that are created based on a condition in an ahead-of-time optimized application, you have to set up the environment when building the application. | ||
The beans which are created while ahead-of-time processing at build time are then always created when running the application and can't be switched off. | ||
To do this, you can set the profiles which should be used when building the application. | ||
|
||
For Maven, this works by setting the `profiles` configuration of the `spring-boot-maven-plugin:process-aot` execution: | ||
|
||
[source,xml,indent=0,subs="verbatim"] | ||
---- | ||
<profile> | ||
<id>native</id> | ||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>process-aot</id> | ||
<configuration> | ||
<profiles>profile-a,profile-b</profiles> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
</profile> | ||
---- | ||
|
||
For Gradle, you need to configure the `ProcessAot` task: | ||
|
||
[source,gradle,indent=0,subs="verbatim"] | ||
---- | ||
tasks.withType(org.springframework.boot.gradle.tasks.aot.ProcessAot).configureEach { | ||
args('--spring.profiles.active=profile-a,profile-b') | ||
} | ||
---- | ||
|
||
Profiles which only change configuration properties that don't influence conditions are supported without limitations when running ahead-of-time optimized applications. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters