I. Preparation and execution of orders
Learning Plug-ins:
Learn the Apache packaging plugin maven-assembly-plugin:http://maven.apache.org/plugins/maven-assembly-plugin/usage.html
To execute a command:
will be typed into the jar package, execute Java-jar xxx.jar, you can.
Two, main method to make Jar package, and reference third party maven jar package
Scenario One: Using the Assembly plugin
1. The build that is configured inside the Pom.xml
1 <build> 2 <plugins> 3 <plugin> 4 <groupid>org.apache.mav En.plugins</groupid> 5 <artifactId>maven-assembly-plugin</artifactId> 6 <version>2.3</version> 7 <configuration> 8 <archive> 9 <manifest> <!--<addclasspath>true</addclasspath> ; --> <mainClass>com.pasier.dbutil.DB2Mysql</mainClass> 12 </manifest> </archive> <descriptors> 15 <descriptor>assembly.xml</descriptor> </descriptors> 17 </configuration> <executions> <execution> 20 <id>makE-assembly</id> <!--This is used for inheritance merges--> 22 <phase>package</phase> <!--bind to the packaging phase--> 24 <goals> <goal>single</goal> ;/goals> </execution> </executions> </plugin>
; </plugins> </build>
The Assembly.xml file description is referenced in
2.pom
1 <assembly xmlns=" http://maven.apache.org/plugins/maven-assembly-plugin/ assembly/1.1.2 "2 xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance "3 xsi:schemalocation=" Http://maven.apach e.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd "> 4 <id >uberjar</id> 5 <formats> 6 <format>jar</format> 7 </formats> 8 <include Basedirectory>false</includebasedirectory> 9 <dependencySets> <dependencySet> One < unpack>true</unpack> <scope>runtime</scope> </dependencySet> </dependen cysets> <fileSets> <fileSet> <directory>${project.build.outputdirectory}</dir ectory> <outputDirectory>/</outputDirectory> </fileSet> </fileSets> ;/assembly>
A simple description of the:<unpack> property refers to whether the referenced Third-party jar package is uncompressed and, if true, to extract the Third-party jar package as a separate file directory or, if False, the third party jar package into your project jar package.
See the figure below, for the <unpack>true</unpack> attributes extracted after the org of Apache, SLF4J, etc. reference class file directory:
3.maven Jar Pack Command