How to run MAVEN projects under the LINUXT system

Source: Internet
Author: User

How to run MAVEN projects under the LINUXT system

We know that it is very common to use MAVEN to manage Java projects. For example, companies generally have their own Maven warehouse, through the MAVEN warehouse to solve our project dependencies, more convenient to build projects. But how do we generate jar packages and run them on Linux servers? What if a jar dependency is involved with some third parties? Now, write down my experiences and share them with you.

First, we're going to export the code as a jar, this step, We can do this without using the Maven plugin, because if you take advantage of the Maven plugin, the executable jar needs to be configured and cumbersome, and you can export the jar directly using Eclipse's export function and specify the main function to run.

Second, we need a maven-dependent jar package. Be aware that the jar packages specified in the Pom.xml are downloaded to the local. M2/repository, how do we get a dependent jar to put them all into the Lib directory? It is obviously not good to copy the jar package under the m2/repository. We can use MAVEN's commands to complete the copy jar package work. Here's how:

After entering the project's root directory, execute

MVN Dependency:copy-dependencies-doutputdirectory=target/lib

In this case, in the target directory, there is a Lib directory in the project required by the jar package is copied here.


Finally, java-djava.ext.dirs=./lib/-jar./xxx.jar

Because we are specifying the JAR option to run, we cannot use the CLASSPATH option to indicate the path to the third-party jar, because the classpath is invalid at this time. But we can use-djava.ext.dirs to make a simple designation.

How to run MAVEN projects under the LINUXT system

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.