diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc index 12e55041d65..708efabab5c 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto.adoc @@ -49,4 +49,6 @@ include::howto/testing.adoc[] include::howto/build.adoc[] +include::howto/aot.adoc[] + include::howto/traditional-deployment.adoc[] diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/aot.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/aot.adoc new file mode 100644 index 00000000000..8ed5cae6421 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/howto/aot.adoc @@ -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. +<> 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"] +---- + + native + + + + + org.springframework.boot + spring-boot-maven-plugin + + + process-aot + + profile-a,profile-b + + + + + + + + +---- + +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. diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/native-image/introducing-graalvm-native-images.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/native-image/introducing-graalvm-native-images.adoc index e76ba9d60e8..d86ea34005a 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/native-image/introducing-graalvm-native-images.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/native-image/introducing-graalvm-native-images.adoc @@ -43,7 +43,7 @@ A closed-world assumption implies the following restrictions: * The classpath is fixed and fully defined at build time * The beans defined in your application cannot change at runtime, meaning: - - The Spring `@Profile` annotation and profile-specific configuration is not supported +- The Spring `@Profile` annotation and profile-specific configuration <>. - Properties that change if a bean is created are not supported (for example, `@ConditionalOnProperty` and `.enable` properties). When these restrictions are in place, it becomes possible for Spring to perform ahead-of-time processing during build-time and generate additional assets that GraalVM can use.