maven-shade-plugin

Using the plug-in maven-shade-plugin is very easy to
use. Using the plug-in maven-shade-plugin can easily export the project as a jar package. The advantage of the plug-in is that it will encapsulate other jar packages that the project depends on. This kind of The jar package can be run directly on any JVM.


Usage steps:

Add the plugin to pom.xml, the place to be changed is mainClass, specify the location of the main method here,

use mvn package to package, and finally go to projectName/target/ to find the target jar package

<build>
        <plugins>
<!-- The shade plugin is packaged into a jar package-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>xxx.xxx</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>


Assembly plugin:
<!-- assembly plugin is packaged into a jar package -->
<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.4.1</version>
                <configuration>
                    <!-- get all project dependencies -->
                    <descriptorRefs>
                        <descriptorRef>jar-with-dependencies</descriptorRef>
                    </descriptorRefs>
                    <!-- MainClass in mainfest make a executable jar -->
                    <archive>
                      <manifest>
                        <mainClass>xxx.xxx</mainClass>
                      </manifest>
                    </archive>
 
                </configuration>
                <executions>
                  <execution>
                    <id>make-assembly</id>
                                        <!-- bind to the packaging phase -->
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                  </execution>
                </executions>
            </plugin>


Reference: http://www.myexception.cn/other/1960512.html

http://www.blogjava.net/qileilove/articles/410887.html

Maven Shade Plugin Getting Started Guide
http://www.jianshu.com/p /7a0e20b30401

Resource Transformers
http://maven.apache.org/plugins/maven-shade-plugin/examples/resource-transformers.htmlSummary

of commonly used Maven pluginshttps:
//my.oschina.net/u/1387007/blog/519581


http://stackoverflow.com/questions/21718357/using-different-properties-files-for-runnable-jars-maven-eclipse

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326803224&siteId=291194637