Eclipse maven Project exported as Jar package

Source: Internet
Author: User

A MAVEN project has a lot of dependencies, so the final jar is usually a lot, and it's bigger, and the steps to make the jar package (note that the package type in the Pom.xml file cannot be a war package):

1. Make a jar of the libraries that depend on Pom.xml:

In the directory where the project Pom.xml is located, execute the command:

MVN dependency:copy-dependencies

The jar packages that you depend on are exported to the directory target/dependency/.

2. Make the MAVEN project into a jar package:

In the directory where the project Pom.xml is located, execute the command:

MVN Package

The project's jar package is exported to the directory target/.

3. Add the jar packages generated in steps 1 and 2 to the new project's Java build Path to use the classes and functions of the above MAVEN project in the new project.

Also, note that the package type of the Pom.xml file cannot be a war package when you make a jar package, and if you do not make a jar package and use the project's dependencies directly in the Java EE, the package type of the Pom.xml file will be the war package.

Eclipse maven Project exported as Jar package

Related Article

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.