loaderImplementation=CLASSIC doesn't work with spring boot maven after spring boot 3.2.x, but Gradle plugin works.
I want to use the classical boot loader for some old library. related to this release notes: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.2-Release-Notes#nested-jar-support
can reproduce this with https://start.spring.io/, create a simple web application, maven package a fat jar, found the fat jar always didn't change with or without this configuration.
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<loaderImplementation>CLASSIC</loaderImplementation>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Comment From: bclozel
found the the jar always didn't change with or without this configuration.
This part is not clear to me. Please elaborate.
Comment From: nicolas-zheng
found the the jar always didn't change with or without this configuration.
This part is not clear to me. Please elaborate. I want to use the classical boot loader for some old library. related to this part: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.2-Release-Notes#nested-jar-support
Comment From: bclozel
I still don't get it.
Please describe: * what are you doing precisely (sharing a minimal sample app is even better) * what behavior you are expecting * what behavior you are seeing instead and why it's wrong
Comment From: nicolas-zheng
with this config, I still got the new boot loader class in the fat jar
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<loaderImplementation>CLASSIC</loaderImplementation>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Comment From: bclozel
But the classic implementation is still being used in this case, isn't it? Why would you assume that the loader class would be filtered out of the resulting JAR?
Comment From: nicolas-zheng
But the classic implementation is still being used in this case, isn't it? Why would you assume that the loader class would be filtered out of the resulting JAR?
classic implementation is not used after spring boot 3.2.0, I want to fallback for some old library. Thanks!
If you do find issues with the new implementation, however, we have provided a fallback option that will allow you to use the old code. For Gradle users you can set the bootJar.loaderImplementation to org.springframework.boot.loader.tools.LoaderImplementation.CLASSIC.
Comment From: bclozel
How to reproduce the issue:
- create a maven project on start.spring.io
- Use the configuration for the CLASSIC nested Jar implementation
- run
./mvnw package - the packaged archive does not contain the classic implementation, only the new one:
jar -tvf target/demo-0.0.1-SNAPSHOT.jar | grep JarLauncher
855 Fri Feb 01 00:00:00 CET 1980 org/springframework/boot/loader/launch/JarLauncher.class
Comment From: wilkinsona
<id>repackage</id> was missing from the configuration. It should be:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<loaderImplementation>CLASSIC</loaderImplementation>
</configuration>
</execution>
</executions>
</plugin>
I've corrected that on the wiki.
Comment From: bclozel
Thanks @wilkinsona I totally missed that bit and was looking into our integration tests (which are all good).