Maven shade pludin (maven-shade-plugin) is used for creating single executable JAR file with all dependencies (libraries) inside. Works also for Spring/Hibernate frameworks (one-jar plugin usage could cause problems with Hibernate access to jar file contents i.e. exception like HHH015010: Unable to find file - just use maven-shade instead).
Basic usage:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven.shade.version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</configuration>
</plugin>
The most frequent issues with this plug-in are the following:
2. Can't execute jar- file: “no main manifest attribute”
Solution: add the following transformer (<configuration> <transformers> section):
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.your.main.Class</mainClass>
</transformer>
3. Spring namespace issues (i.e. Unable to locate Spring NamespaceHandler for XML schema)
Solution: add the following transformers (<configuration> <transformers> section):
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.handlers</resource>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
<resource>META-INF/spring.schemas</resource>
</transformer>
4. Security issues when running jar (i.e. Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes)
Solution: add the following filter (<configuration> <filters> section):
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
0 коментарі:
Дописати коментар