Type the main method into a jar package and reference a third party Maven jar package __svn-github-maven

Source: Internet
Author: User
Tags unpack
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&gt ;                         --> <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&gt
; </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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.