Basic java applications that do not depends upond Spring but that still use the spring-boot-maven-plugin
to repackage and/or to build a docker image, will encounter a java.lang.ClassNotFoundException: org.springframework.util.ClassUtils
when trying to use java -Djarmode=layertools -jar target/xxx.jar list
.
To resolve this ClassNotFoundException, the application MUST include a dependency to org.springframework:spring-core
which immediatly add 1.4Mo to the application size!
- It would be nice if the requiered classes would be recopied into the
spring-boot-jarmode-layertools-2.5.2.jar
so that this jar is standalone. - It would be nice to store the
spring-boot-jarmode-layertools-2.5.2.jar
and any accompagning jar (like spring-jcl.jar) into their own layer so that one can ignore them when copying the layers into the final image - assuming those dependencies will not be of any use to the dockerised application.
Comment From: wilkinsona
Our primary focus is on application that use Spring. While we could copy the necessary classes from spring-core
into the layer tools jar, this would bloat the archive for anyone building a Spring-based application as some classes would now be duplicated. If you want to be able to use layertools then you'll have to include spring-core
in your app.
If you don't want to use layertools, you can exclude it by configuring your build appropriately. The documentation for the Gradle and Maven plugins describes how to do so.