Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

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 calledpaketo-buildpacks/bellsoft-liberica which is based onBellsoft Liberica JDK.

The list of all Java buildpacks is available inPaketo Buildpacks Reference.

To choose another JVM in spring-boot-maven-plugin, first you need to find the buildpacks that are used by default. Runmvn 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 modeExit fullscreen mode

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

So, to useMicrosoft OpenJDK, copy the buildpacks from above, but changepaketo-buildpacks/bellsoft-liberica togcr.io/paketo-buildpacks/microsoft-openjdk. Thepom.xml should be:

<plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><image><buildpacks><buildpack>paketo-buildpacks/ca-certificates</buildpack><buildpack>gcr.io/paketo-buildpacks/microsoft-openjdk</buildpack><buildpack>paketo-buildpacks/syft</buildpack><buildpack>paketo-buildpacks/executable-jar</buildpack><buildpack>paketo-buildpacks/dist-zip</buildpack><buildpack>paketo-buildpacks/spring-boot</buildpack></buildpacks></image></configuration></plugin>
Enter fullscreen modeExit fullscreen mode

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

[INFO]     [creator]     Paketo Buildpack for Microsoft OpenJDK 3.0.1[INFO]     [creator]       https://github.com/paketo-buildpacks/microsoft-openjdk...[INFO]     [creator]       Microsoft OpenJDK 17.0.6: Contributing to layer[INFO]     [creator]         Downloading from https://aka.ms/download-jdk/microsoft-jdk-17.0.6-linux-x64.tar.gz
Enter fullscreen modeExit fullscreen mode

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Software architect, developer, learner.
  • Location
    São Paulo
  • Joined

More fromEduardo Issao Ito

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp