DEV Community

Eduardo Issao Ito
Eduardo Issao Ito

Posted on

Changing the JVM in spring-boot:build-image

The spring-boot-maven-plugin can create an OCI image from a jar or war file using Cloud Native Buildpacks.

By default it uses a buildpack called paketo-buildpacks/bellsoft-liberica which is based on Bellsoft Liberica JDK.

The list of all Java buildpacks is available in Paketo Buildpacks Reference.

To choose another JVM in spring-boot-maven-plugin, first you need to find the buildpacks that are used by default. Run mvn spring-boot:build-image and look for something like this:

[INFO]     [creator]     ===> DETECTING
[INFO]     [creator]     6 of 26 buildpacks participating
[INFO]     [creator]     paketo-buildpacks/ca-certificates   3.6.1
[INFO]     [creator]     paketo-buildpacks/bellsoft-liberica 10.1.0
[INFO]     [creator]     paketo-buildpacks/syft              1.27.0
[INFO]     [creator]     paketo-buildpacks/executable-jar    6.6.3
[INFO]     [creator]     paketo-buildpacks/dist-zip          5.5.2
[INFO]     [creator]     paketo-buildpacks/spring-boot       5.23.0
Enter fullscreen mode Exit fullscreen mode

That´s the list of buildpacks being used. We need to change Bellsoft Liberica to the desired JVM.

So, to use Microsoft OpenJDK, copy the buildpacks from above, but change paketo-buildpacks/bellsoft-liberica to The pom.xml should be:

Enter fullscreen mode Exit fullscreen mode

Now, run mvn spring-boot:build-image and verify that Microsoft OpenJDK is being used:

[INFO]     [creator]     Paketo Buildpack for Microsoft OpenJDK 3.0.1
[INFO]     [creator]
[INFO]     [creator]       Microsoft OpenJDK 17.0.6: Contributing to layer
[INFO]     [creator]         Downloading from
Enter fullscreen mode Exit fullscreen mode

Top comments (0)