Mvn-play jar Run Package (with environment variable Configuration)

Source: Internet
Author: User

Frontier conditions

Maven Download: http://maven.apache.org/download.cgi

Configuring Environment variables

      Maven_home= D:\Softwares\apache-maven-3.2.2

PATH

To add;%maven_home%\bin; to the Tail.

CMD test is configured successfully

Input Mvn-v

Maven exports all jars of the project

Enter the directory where the project Pom.xml is located and execute the following command:

MVN dependency:copy-dependencies

Directory exists (export jar will present default directory Target/dependency)

how to export to a custom directory

Export to a custom directory under the Maven project, create the Lib folder, and enter the following command: 1, mvn dependency:copy-dependencies-doutputdirectory=lib; 2, The jar packages that the MAVEN project relies on are copied to the Lib directory under the project Directory.

You can set the dependency level

Usually use compile level mvn dependency:copy-dependencies-doutputdirectory=lib-dincludescope=compile

Enter the body to play jar runnable package

Through MAVEN to the package is basically through the Pom.xml configuration information

Packing action

Packaging jar Package Conditions

Play Jar Package Existing plug-in

Learning Sources:

http://chenzhou123520.iteye.com/blog/1706242

http://chenzhou123520.iteye.com/blog/1971322

http://blog.csdn.net/bluishglc/article/details/7596118

Maven-assembly-plugin

Configuring plug-in information in the Pom.xml plugin

<plugin>      <Artifactid>Maven-assembly-plugin</Artifactid>      <Configuration>          <Appendassemblyid>False</Appendassemblyid>          <Descriptorrefs>              <Descriptorref>Jar-with-dependencies</Descriptorref>          </Descriptorrefs>          <Archive>              <Manifest>                  <MainClass>Com. Maintest</MainClass>   <!--full path of main class running -            </Manifest>          </Archive>      </Configuration>      <executions>          <Execution>              <ID>make-assembly</ID>              <Phase>Package</Phase>              <Goals>                  <goal>Assembly</goal>              </Goals>          </Execution>      </executions>  </plugin>  

Where the value of <mainClass></mainClass> represents the entry class for this project, which is the class containing the Main method

There are two ways of packaging execution:

1. Right-click on the Project-"run as-" maven install2. execute MVN directly to the project root assembly:assembly

It will eventually generate two jars in the target directory of the project, a jar with a third-party package, a jar without a Third-party package

Maven-shade-plugin

POM Configuration (recommended)

<plugin>      <groupId>Org.apache.maven.plugins</groupId>      <Artifactid>Maven-shade-plugin</Artifactid>      <version>1.7.1</version>      <executions>          <Execution>              <Phase>Package</Phase>              <Goals>                  <goal>Shade</goal>              </Goals>              <Configuration>                  <Transformers>                      <TransformerImplementation= "org.apache.maven.plugins.shade.resource.AppendingTransformer">                          <Resource>Meta-inf/spring.handlers</Resource>                      </Transformer>                      <TransformerImplementation= "org.apache.maven.plugins.shade.resource.AppendingTransformer">                          <Resource>Meta-inf/spring.schemas</Resource>                      </Transformer>                      <TransformerImplementation= "org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">                          <MainClass>Com. Maintest</MainClass>                      </Transformer>                  </Transformers>              </Configuration>          </Execution>      </executions>  </plugin>  

Mvn-play jar Run Package (with environment variable Configuration)

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.