When trying to use the default Shade plugin configuration with Maven that is inherited form spring-boot-starter-parent, I get the following error from Maven:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-shade-plugin:2.1:shade (default) on project spring-boot-example:
Unable to parse configuration of mojo org.apache.maven.plugins:maven-shade-plugin:2.1:shade for parameter transformers:
Cannot load implementation hint 'org.springframework.maven.packaging.PropertiesMergingResourceTransformer'
-> [Help 1]
My POM in this case looks like:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
</plugin>
</plugins>
</build>
I think the package name of PropertiesMergingResourceTransformer should be org.springframework.boot.maven.PropertiesMergingResourceTransformer
I've tried the following POM and it generated a proper shaded jar and is working correctly:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer
implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer">
<resource>META-INF/spring.factories</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>${start-class}</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Thanks for the analysis.
thank
Thanks very much!~ For this questions it cost me half of one day~_~
I succeeded in building the project using your method.but the generated jar package failed to run and there was a 'java.lang.ClassNotFounfException' error.
@tokerr This issue was closed in 2014. If you have a question, please ask on stackoverflow.com
@davibo solution works, additionally the auto-generated pom.xml doesn't set the version correctly.
no main manifest attribute, error in built fat jar
@Nikkithakur this issue was closed over 5 years ago. If you have a question, please ask on StackOverflow. If you believe you've found a bug, please create a new issue with a small sample (zip or github repo) we can run ourselves.
Most helpful comment
I succeeded in building the project using your method.but the generated jar package failed to run and there was a 'java.lang.ClassNotFounfException' error.