12 changed files with 126 additions and 99 deletions
@ -0,0 +1,64 @@
@@ -0,0 +1,64 @@
|
||||
[[packaging.aot-cache]] |
||||
= AOT Cache |
||||
|
||||
AOT cache is a https://openjdk.org/jeps/483[JVM feature] that can help reduce the startup time and memory footprint of Java applications. |
||||
|
||||
If you're using Java < 24, you should read the sections about CDS. |
||||
CDS is the predecessor of AOT cache, but works similarly. |
||||
|
||||
Spring Boot supports both CDS and AOT cache, and it is recommended that you use AOT cache if it is available in the JVM version you are using (Java 24 or later). |
||||
|
||||
[[packaging.aot-cache.aot-cache]] |
||||
== AOT Cache |
||||
|
||||
NOTE: If you're using Java < 24, AOT cache is not available. |
||||
You have to use CDS instead. |
||||
|
||||
To use the AOT cache feature, you should first perform a training run on your application in extracted form: |
||||
|
||||
[source,shell] |
||||
---- |
||||
$ java -Djarmode=tools -jar my-app.jar extract --destination application |
||||
$ cd application |
||||
$ java -XX:AOTCacheOutput=app.aot -Dspring.context.exit=onRefresh -jar my-app.jar |
||||
---- |
||||
|
||||
This creates an `app.aot` cache file that can be reused as long as the application is not updated and the same Java version is used. |
||||
|
||||
To use the cache file, you need to add an extra parameter when starting the application: |
||||
|
||||
[source,shell] |
||||
---- |
||||
$ java -XX:AOTCache=app.aot -jar my-app.jar |
||||
---- |
||||
|
||||
NOTE: You have to use the cache file with the extracted form of the application, otherwise it has no effect. |
||||
|
||||
|
||||
|
||||
[[packaging.aot-cache.cds]] |
||||
== CDS |
||||
|
||||
NOTE: If you're using Java 24 or later, please use AOT cache instead of CDS. |
||||
|
||||
To use CDS, you should first perform a training run on your application in extracted form: |
||||
|
||||
[source,shell] |
||||
---- |
||||
$ java -Djarmode=tools -jar my-app.jar extract --destination application |
||||
$ cd application |
||||
$ java -XX:ArchiveClassesAtExit=application.jsa -Dspring.context.exit=onRefresh -jar my-app.jar |
||||
---- |
||||
|
||||
This creates an `application.jsa` archive file that can be reused as long as the application is not updated. |
||||
|
||||
To use the archive file, you need to add an extra parameter when starting the application: |
||||
|
||||
[source,shell] |
||||
---- |
||||
$ java -XX:SharedArchiveFile=application.jsa -jar my-app.jar |
||||
---- |
||||
|
||||
NOTE: You have to use the cache file with the extracted form of the application, otherwise it has no effect. |
||||
|
||||
NOTE: For more details about CDS, refer to the https://docs.oracle.com/en/java/javase/17/vm/class-data-sharing.html[Class Data Sharing documentation of the JDK]. |
||||
@ -1,53 +0,0 @@
@@ -1,53 +0,0 @@
|
||||
[[packaging.class-data-sharing]] |
||||
= Class Data Sharing |
||||
|
||||
Class Data Sharing (CDS) is a https://docs.oracle.com/en/java/javase/17/vm/class-data-sharing.html[JVM feature] that can help reduce the startup time and memory footprint of Java applications. |
||||
|
||||
In Java 24, CDS is succeeded by the AOT Cache via https://openjdk.org/jeps/483[JEP 483]. |
||||
Spring Boot supports both CDS and AOT cache, and it is recommended that you use the latter if it is available in the JVM version you are using (Java 24+). |
||||
|
||||
[[packaging.class-data-sharing.cds]] |
||||
== CDS |
||||
|
||||
To use CDS, you should first perform a training run on your application in extracted form: |
||||
|
||||
[source,shell] |
||||
---- |
||||
$ java -Djarmode=tools -jar my-app.jar extract --destination application |
||||
$ cd application |
||||
$ java -XX:ArchiveClassesAtExit=application.jsa -Dspring.context.exit=onRefresh -jar my-app.jar |
||||
---- |
||||
|
||||
This creates an `application.jsa` archive file that can be reused as long as the application is not updated. |
||||
|
||||
To use the archive file, you need to add an extra parameter when starting the application: |
||||
|
||||
[source,shell] |
||||
---- |
||||
$ java -XX:SharedArchiveFile=application.jsa -jar my-app.jar |
||||
---- |
||||
|
||||
NOTE: For more details about CDS, refer to the xref:how-to:class-data-sharing.adoc[CDS how-to guide] and the {url-spring-framework-docs}/integration/cds.html[Spring Framework reference documentation]. |
||||
|
||||
[[packaging.class-data-sharing.aot-cache]] |
||||
== AOT Cache |
||||
|
||||
To use the AOT cache, you should first perform a training run on your application in extracted form: |
||||
|
||||
[source,shell] |
||||
---- |
||||
$ java -Djarmode=tools -jar my-app.jar extract --destination application |
||||
$ cd application |
||||
$ java -XX:AOTMode=record -XX:AOTConfiguration=app.aotconf -Dspring.context.exit=onRefresh -jar my-app.jar |
||||
$ java -XX:AOTMode=create -XX:AOTConfiguration=app.aotconf -XX:AOTCache=app.aot -jar my-app.jar |
||||
---- |
||||
|
||||
This creates an `app.aot` cache file that can be reused as long as the application is not updated. |
||||
The intermediate `app.aotconf` file is no longer needed and can be safely deleted. |
||||
|
||||
To use the cache file, you need to add an extra parameter when starting the application: |
||||
|
||||
[source,shell] |
||||
---- |
||||
$ java -XX:AOTCache=app.aot -jar my-app.jar |
||||
---- |
||||
@ -1,7 +1,7 @@
@@ -1,7 +1,7 @@
|
||||
[[packaging]] |
||||
= Packaging Spring Boot Applications |
||||
|
||||
Spring Boot supports several technologies for optimizing applications for deployment, including xref:packaging/native-image/index.adoc[GraalVM native images], xref:packaging/class-data-sharing.adoc[Class Data Sharing], and xref:packaging/checkpoint-restore.adoc[Checkpoint and Restore]. |
||||
Spring Boot supports several technologies for optimizing applications for deployment, including xref:packaging/native-image/index.adoc[GraalVM native images], xref:packaging/aot-cache.adoc[AOT cache], and xref:packaging/checkpoint-restore.adoc[Checkpoint and Restore]. |
||||
|
||||
Spring Boot applications can be packaged in Docker containers using techniques described in xref:packaging/container-images/index.adoc[]. |
||||
|
||||
|
||||
Loading…
Reference in new issue