I am aware of two approaches. Below are Dockerfile snippets.
# This approach generates and runs application classes stored in the `extracted_layers/application/BOOT-INF/classes/` folder.
.
.
.
RUN java -Djarmode=layertools -jar app.jar extract --destination extracted_layers
.
.
.
ENTRYPOINT ["java", "-XX:+UseContainerSupport", "-XX:MaxRAMPercentage=75.0", "-XX:+UseG1GC", "org.springframework.boot.loader.launch.JarLauncher"]
# This approach generates and runs the application jar stored in the `extracted_layers/application/` folder
.
.
.
RUN java -Djarmode=tools -jar app.jar extract --layers --destination extracted_layers
.
.
.
ENTRYPOINT ["java", "-XX:+UseContainerSupport", "-XX:MaxRAMPercentage=75.0", "-XX:+UseG1GC", "-jar", "app.jar"]
Notice the difference in the tool used specified by -Djarmode .
The documentation uses the jar approach: https://docs.spring.io/spring-boot/3.5/reference/packaging/container-images/dockerfiles.html
I would think that using the extracted classes provides a faster startup.