diff --git a/spring-boot-project/spring-boot-docs/src/docs/antora/modules/how-to/pages/class-data-sharing.adoc b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/how-to/pages/class-data-sharing.adoc new file mode 100644 index 0000000000..a00e21d983 --- /dev/null +++ b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/how-to/pages/class-data-sharing.adoc @@ -0,0 +1,20 @@ +[[howto.class-data-sharing]] += Class Data Sharing + +This section includes information about using Class Data Sharing (CDS) with Spring Boot applications. +For an overview of Spring Boot support for CDS, see xref:reference:packaging/class-data-sharing.adoc[Class Data Sharing]. + + +[[howto.class-data-sharing.buildpacks]] +== Packaging an Application Using CDS and Buildpacks + +Spring Boot's xref:reference:packaging/container-images/cloud-native-buildpacks.adoc[support for Cloud Native Buildpacks] along with the https://paketo.io/docs/reference/java-reference[Paketo Java buildpack] and its https://paketo.io/docs/reference/java-reference/#spring-boot-applications[Spring Boot support] can be used to generate a Docker image containing a CDS-optimized application. + +To enable CDS optimization in a generated Docker image, the buildpack environment variable `BP_JVM_CDS_ENABLED` should be set to `true` when building the image as described in the xref:maven-plugin:build-image.adoc#build-image.examples.builder-configuration[Maven plugin] and xref:gradle-plugin:packaging-oci-image.adoc#build-image.examples.builder-configuration[Gradle plugin] documentation. +This will cause the buildpack to do a training run of the application, save the CDS archive in the image, and use the CDS archive when launching the application. + +The buildpack environment variable `BP_SPRING_AOT_ENABLED` can also be set to `true` to enable AOT mode along with CDS when running an application that has been xref:reference:packaging/aot.adoc[built with Ahead-of-Time processed]. + +The Paketo Buildpack for Spring Boot https://github.com/paketo-buildpacks/spring-boot?tab=readme-ov-file#configuration[documentation] has information on other configuration options that can be enabled with builder environment variables. + + diff --git a/spring-boot-project/spring-boot-docs/src/docs/antora/modules/how-to/partials/nav-how-to.adoc b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/how-to/partials/nav-how-to.adoc index 68e5f21f5d..d1dabaeb73 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/antora/modules/how-to/partials/nav-how-to.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/how-to/partials/nav-how-to.adoc @@ -21,6 +21,7 @@ ** xref:how-to:native-image/index.adoc[] *** xref:how-to:native-image/developing-your-first-application.adoc[] *** xref:how-to:native-image/testing-native-applications.adoc[] +** xref:how-to:class-data-sharing.adoc[] ** xref:how-to:deployment/index.adoc[] *** xref:how-to:deployment/traditional-deployment.adoc[] *** xref:how-to:deployment/cloud.adoc[] diff --git a/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/packaging/class-data-sharing.adoc b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/packaging/class-data-sharing.adoc index 6d2896c28b..6259adfa0d 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/packaging/class-data-sharing.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/antora/modules/reference/pages/packaging/class-data-sharing.adoc @@ -3,7 +3,7 @@ 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. -To use it, you should first perform a training run on your application in exploded form: +To use it, you should first perform a training run on your application in extracted form: [source,shell] ----