You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/packaging/class-data-sharing.adoc
+7-2Lines changed: 7 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,8 +3,11 @@
3
3
4
4
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.
5
5
6
-
In Java 24, CDS is succeeded by the AOT Cache via https://openjdk.org/jeps/483[JEP 483].
7
-
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+).
6
+
If you are using Java 25 or above, CDS has been succeeded by the AOT Cache via https://openjdk.org/jeps/483[JEP 483].
7
+
8
+
NOTE: Spring Boot supports both CDS and AOT cache, however, we recommend using the AOT cache whenever possible.
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].
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/packaging/container-images/dockerfiles.adoc
+24-18Lines changed: 24 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -57,15 +57,38 @@ Additionally, the layout created by the `jarmode` is CDS and AOT cache friendly
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`:
64
+
[source,dockerfile]
65
+
----
66
+
include::reference:partial$dockerfile[]
67
+
68
+
# Execute the AOT cache training run
69
+
RUN java -XX:AOTCacheOutput=app.aot -Dspring.context.exit=onRefresh -jar application.jar
70
+
71
+
# Start the application jar with AOT cache enabled - this is not the uber jar used by the builder
72
+
# This jar only contains application code and references to the extracted jar files
73
+
# This layout is efficient to start up and AOT cache friendly
This is mostly the same as the above `Dockerfile`.
78
+
As the last steps, it creates the AOT cache file by doing a training run and passes the AOT cache parameter to `java -jar`.
79
+
80
+
60
81
[[packaging.container-images.dockerfiles.cds]]
61
82
== CDS
62
83
63
84
If you want to additionally enable xref:reference:packaging/class-data-sharing.adoc#packaging.class-data-sharing.cds[CDS], you can use this `Dockerfile`:
64
85
[source,dockerfile]
65
86
----
66
87
include::reference:partial$dockerfile[]
88
+
67
89
# Execute the CDS training run
68
90
RUN java -XX:ArchiveClassesAtExit=application.jsa -Dspring.context.exit=onRefresh -jar application.jar
91
+
69
92
# Start the application jar with CDS enabled - this is not the uber jar used by the builder
70
93
# This jar only contains application code and references to the extracted jar files
71
94
# This layout is efficient to start up and CDS friendly
If you 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`:
82
-
[source,dockerfile]
83
-
----
84
-
include::reference:partial$dockerfile[]
85
-
# Execute the AOT cache training run
86
-
RUN java -XX:AOTMode=record -XX:AOTConfiguration=app.aotconf -Dspring.context.exit=onRefresh -jar application.jar
87
-
RUN java -XX:AOTMode=create -XX:AOTConfiguration=app.aotconf -XX:AOTCache=app.aot -jar application.jar && rm app.aotconf
88
-
# Start the application jar with AOT cache enabled - this is not the uber jar used by the builder
89
-
# This jar only contains application code and references to the extracted jar files
90
-
# This layout is efficient to start up and AOT cache friendly
0 commit comments