I am using maven-shade-plugin along with Sprint Boot. I have defined spring-boot dependencies as:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.0.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
I already have my project specific uber-pom defined in <parent>
tag of my pom.xml so not able to use spring-boot-starter-parent
in <parent>
tag.
Now, when I do mvn clean install
, I get below exception :
`[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:3.1.1:shade (default) on project myapp: Unable to parse configuration of mojo org.apache.maven.plugins:maven-shade-plugin:3.1.1:shade for parameter transformers: Cannot load implementation hint 'org.springframework.boot.maven.PropertiesMergingResourceTransformer'`,
which clearly says implementation of PropertiesMergingResourceTransformer
cannot be found. If I use Spring-boot configuration as defined in <parent>
tag, it works fine.
However, if I completely remove PropertiesMergingResourceTransformer
configuration in maven-shade-plugin configuration, then bundled jar cannot be executed, and give exception as below :
`java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.
at org.springframework.util.Assert.notEmpty(Assert.java:450) ~[myapp-1.0-SNAPSHOT.jar:na]
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getCandidateConfigurations(AutoConfigurationImportSelector.java:160) ~[myapp-1.0-SNAPSHOT.jar:na]
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.selectImports(AutoConfigurationImportSelector.java:96) ~[myapp-1.0-SNAPSHOT.jar:na]`
Can somebody help in this.
For reference : This is the maven-shade-plugin issue which was resolved : https://github.com/spring-projects/spring-boot/issues/11200
But it seems to work only if spring-boot dependencies are configured in <parent>
tag and not in <dependencyManagement>
While trying to use spring-boot-maven-plugin I get below exception while running the jar:
`Exception in thread "main" java.lang.IllegalStateException: Failed to get nested archive for entry BOOT-INF/lib/spring-boot-2.0.2.RELEASE.jar
at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchive(JarFileArchive.java:108)
at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchives(JarFileArchive.java:86)
at org.springframework.boot.loader.ExecutableArchiveLauncher.getClassPathArchives(ExecutableArchiveLauncher.java:70)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:49)
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51)
Caused by: java.io.IOException: Unable to open nested jar file 'BOOT-INF/lib/spring-boot-2.0.2.RELEASE.jar'
at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:254)
at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:239)
at org.springframework.boot.loader.archive.JarFileArchive.getNestedArchive(JarFileArchive.java:103)
... 4 more
Caused by: java.lang.IllegalStateException: Unable to open nested entry 'BOOT-INF/lib/spring-boot-2.0.2.RELEASE.jar'. It has been compressed and nested jar files must be stored without compression. Please check the mechanism used to create your executable jar file
at org.springframework.boot.loader.jar.JarFile.createJarFileFromFileEntry(JarFile.java:282)
at org.springframework.boot.loader.jar.JarFile.createJarFileFromEntry(JarFile.java:262)
at org.springframework.boot.loader.jar.JarFile.getNestedJarFile(JarFile.java:250)
... 6 more`