This version is still in development and is not considered stable yet. For the latest stable version, please use Spring Boot 3.4.5! |
Class Data Sharing
Class Data Sharing (CDS) is a 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 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+).
CDS
To use CDS, you should first perform a training run on your application in extracted form:
$ 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:
$ java -XX:SharedArchiveFile=application.jsa -jar my-app.jar
For more details about CDS, refer to the CDS how-to guide and the Spring Framework reference documentation. |
AOT Cache
To use the AOT cache, you should first perform a training run on your application in extracted form:
$ 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:
$ java -XX:AOTCache=app.aot -jar my-app.jar