Skip to content

Commit 9051e53

Browse files
committed
Merge branch '3.5.x' into 4.0.x
Closes gh-50484
2 parents 134812f + 10f822e commit 9051e53

3 files changed

Lines changed: 36 additions & 5 deletions

File tree

documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/packaging/aot-cache.adoc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@
44

55
AOT cache is a https://openjdk.org/jeps/483[JVM feature] that can help reduce the startup time and memory footprint of Java applications.
66

7-
If you're using Java < 24, you should read the sections about CDS.
7+
If you are not yet using Java 25 or above, you should read the sections about CDS.
88
CDS is the predecessor of AOT cache, but works similarly.
99

10-
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).
10+
NOTE: Spring Boot supports both CDS and AOT cache, however, we recommend using the AOT cache whenever possible.
11+
12+
1113

1214
[[packaging.aot-cache.aot-cache]]
1315
== AOT Cache
1416

15-
NOTE: If you're using Java < 24, AOT cache is not available.
16-
You have to use CDS instead.
17+
NOTE: Spring Boot supports the AOT cache for Java 25 and above.
18+
If you're using an earlier version of Java, you have to use CDS instead.
1719

1820
To use the AOT cache feature, you should first perform a training run on your application in extracted form:
1921

@@ -40,7 +42,7 @@ NOTE: You have to use the cache file with the extracted form of the application,
4042
[[packaging.aot-cache.cds]]
4143
== CDS
4244

43-
NOTE: If you're using Java 24 or later, please use AOT cache instead of CDS.
45+
NOTE: If you're using Java 25 or above, please use AOT cache instead of CDS.
4446

4547
To use CDS, you should first perform a training run on your application in extracted form:
4648

documentation/spring-boot-docs/src/docs/antora/modules/reference/pages/packaging/container-images/dockerfiles.adoc

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,27 @@ As the last steps, it creates the AOT cache file by doing a training run and pas
7777

7878

7979

80+
[[packaging.container-images.dockerfiles.aot-cache]]
81+
== AOT cache
82+
83+
If you are using Java 25 or above, and want to additionally enable the xref:reference:packaging/class-data-sharing.adoc#packaging.class-data-sharing.aot-cache[AOT cache], you can use this `Dockerfile`:
84+
[source,dockerfile]
85+
----
86+
include::reference:partial$dockerfile[]
87+
88+
# Execute the AOT cache training run
89+
RUN java -XX:AOTCacheOutput=app.aot -Dspring.context.exit=onRefresh -jar application.jar
90+
91+
# Start the application jar with AOT cache enabled - this is not the uber jar used by the builder
92+
# This jar only contains application code and references to the extracted jar files
93+
# This layout is efficient to start up and AOT cache friendly
94+
ENTRYPOINT ["java", "-XX:AOTCache=app.aot", "-jar", "application.jar"]
95+
----
96+
97+
This is mostly the same as the above `Dockerfile`.
98+
As the last steps, it creates the AOT cache file by doing a training run and passes the AOT cache parameter to `java -jar`.
99+
100+
80101
[[packaging.container-images.dockerfiles.cds]]
81102
== CDS
82103

@@ -86,8 +107,10 @@ If you want to additionally enable xref:reference:packaging/aot-cache.adoc#packa
86107
[source,dockerfile]
87108
----
88109
include::reference:partial$dockerfile[]
110+
89111
# Execute the CDS training run
90112
RUN java -XX:ArchiveClassesAtExit=application.jsa -Dspring.context.exit=onRefresh -jar application.jar
113+
91114
# Start the application jar with CDS enabled - this is not the uber jar used by the builder
92115
# This jar only contains application code and references to the extracted jar files
93116
# This layout is efficient to start up and CDS friendly
@@ -96,3 +119,5 @@ ENTRYPOINT ["java", "-XX:SharedArchiveFile=application.jsa", "-jar", "applicatio
96119

97120
This is mostly the same as the above `Dockerfile`.
98121
As the last steps, it creates the CDS archive by doing a training run and passes the CDS parameter to `java -jar`.
122+
123+
NOTE: If you are using Java 25 or above, we recommend using an AOT cache instead of CDS.

documentation/spring-boot-docs/src/docs/antora/modules/reference/partials/dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
# Perform the extraction in a separate builder container
22
FROM bellsoft/liberica-openjre-debian:25-cds AS builder
33
WORKDIR /builder
4+
45
# This points to the built jar file in the target folder
56
# Adjust this to 'build/libs/*.jar' if you're using Gradle
67
ARG JAR_FILE=target/*.jar
8+
79
# Copy the jar file to the working directory and rename it to application.jar
810
COPY ${JAR_FILE} application.jar
11+
912
# Extract the jar file using an efficient layout
1013
RUN java -Djarmode=tools -jar application.jar extract --layers --destination extracted
1114

1215
# This is the runtime container
1316
FROM bellsoft/liberica-openjre-debian:25-cds
1417
WORKDIR /application
18+
1519
# Copy the extracted jar contents from the builder container into the working directory in the runtime container
1620
# Every copy step creates a new docker layer
1721
# This allows docker to only pull the changes it really needs

0 commit comments

Comments
 (0)