Skip to content

Spring boot maven plugin: mvn clean package does not layered jar file automatically

I got trouble with spring-boot-maven-plugin build process. I just want to build

excutable “layered” jar file for optimizing docker image. As document said this build process will produce layered jar by default Here is apart of my pom.xml file


I used spring boot 2.5.5, maven 3.6.3
Some steps produce:

mvn clean package
jar -tf target/[excutableJarFile].jar

This filesystem of excutableJarFile is just BOOT-INF, META-INF and org although it should be

  1. dependencies
  2. spring-boot-loader
  3. snapshot-dependencies
  4. application



Enabling the layering feature of the Spring Boot Maven plugin does not change the layout of the generated jar file. It does enable the generation of a layers.idx file that describes how the application is layered, as described in the Spring Boot documentation.

You can use the layertools mode of the generated jar to extract the contents of the jar into a layered structure. See the Dockerfile example in the documentation for more information on how this works.

5 People found this is helpful