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
+32-3
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,13 @@
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
-
To use it, you should first perform a training run on your application in extracted form:
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+).
8
+
9
+
[[packaging.class-data-sharing.cds]]
10
+
== CDS
11
+
12
+
To use CDS, you should first perform a training run on your application in extracted form:
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].
31
+
32
+
[[packaging.class-data-sharing.aot-cache]]
33
+
== AOT Cache
34
+
35
+
To use the AOT cache, you should first perform a training run on your application in extracted form:
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/packaging/container-images/dockerfiles.adoc
+21-3
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ Here is an example of a `Dockerfile` using `jarmode`.
36
36
include::reference:partial$dockerfile[]
37
37
# Start the application jar - this is not the uber jar used by the builder
38
38
# This jar only contains application code and references to the extracted jar files
39
-
# This layout is efficient to start up and CDS friendly
39
+
# This layout is efficient to start up and CDS/AOT cache friendly
40
40
ENTRYPOINT ["java", "-jar", "application.jar"]
41
41
----
42
42
@@ -53,14 +53,14 @@ Each of the `COPY` commands relates to the layers extracted by the jarmode.
53
53
54
54
Of course, a `Dockerfile` can be written without using the `jarmode`.
55
55
You can use some combination of `unzip` and `mv` to move things to the right layer but `jarmode` simplifies that.
56
-
Additionally, the layout created by the `jarmode` is CDS friendly out of the box.
56
+
Additionally, the layout created by the `jarmode` is CDS and AOT cache friendly out of the box.
57
57
58
58
59
59
60
60
[[packaging.container-images.dockerfiles.cds]]
61
61
== CDS
62
62
63
-
If you want to additionally enable xref:reference:packaging/class-data-sharing.adoc[CDS], you can use this `Dockerfile`:
63
+
If you want to additionally enable xref:reference:packaging/class-data-sharing.adoc#packaging.class-data-sharing.cds[CDS], you can use this `Dockerfile`:
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
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/packaging/efficient.adoc
+1-1
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ Certain PaaS implementations may also choose to extract archives before they run
12
12
For example, Cloud Foundry operates this way.
13
13
14
14
Spring Boot supports extracting your application to a directory using different layouts.
15
-
The default layout is the most efficient, and is xref:reference:packaging/class-data-sharing.adoc[CDS friendly].
15
+
The default layout is the most efficient, and it is xref:reference:packaging/class-data-sharing.adoc#packaging.class-data-sharing.cds[CDS] and xref:reference:packaging/class-data-sharing.adoc#packaging.class-data-sharing.aot-cache[AOT cache] friendly.
16
16
17
17
In this layout, the libraries are extracted to a `lib/` folder, and the application jar
18
18
contains the application classes and a manifest which references the libraries in the `lib/` folder.
0 commit comments