Maven Add local jar Package

Source: Internet
Author: User

Today encountered a Mavan warehouse does not have a jar package, it can only add local jar package, spent a lot of time to find information, finally OK. So this record.

1. For the first time, see on the internet that can be solved with <systemPath>, as follows:

<Dependencies>  <Dependency>    <groupId>Xxx</groupId>    <Artifactid>Xxx</Artifactid>    <version>Xxx</version>    <Scope>System</Scope>    <Systempath>${basedir}/xx.jar</Systempath>  </Dependency></Dependencies>

However, when running jetty and packaging, you will not find the referenced package, pass away directly. All kinds of egg ache, is the MAVEN is not ripe to provoke the curse. The deceased MAVEN official website looked at the document, has made the good few moments, finally found a solution:

2. Create a local warehouse and install it as a plugin:

(1) Create a local repository:

<repositories>  <Repository>    <ID>Local-repo</ID>    <URL>File://${basedir}/repo</URL>  </Repository></repositories>

(2) Install the local library to Maven:

 mvn install:install-file-dfile=<   > -dgroupid=<  Span style= "color: #800000;" >group  >  -dartifactid=  <  artifactid  > -dversion= <  version  > -dpackaging=<  packaging  > -dlocalrepositorypath= path  >  

(Note: Parameter description: Jar-path is the path of your jar, Group,artifactid, version This does not say, packaging is a jar or war, Dlocalrepositorypath is the path of the local repository you created earlier).

(3) Install as plug-in form:

<plugin>    <groupId>Org.apache.maven.plugins</groupId>    <Artifactid>Maven-install-plugin</Artifactid>    <version>2.4</version>    <executions>        <Execution>            <Phase>Initialize</Phase>            <Goals>                <goal>Install-file</goal>            </Goals>            <Configuration>                <groupId>Xxx</groupId>                <Artifactid>Xxx</Artifactid>                <version>Xxx</version>                <Packaging>Jar</Packaging>                <file>${basedir}/xxx.jar</file>            </Configuration>        </Execution>    </executions></plugin>

(4) Add dependency:

<Dependency>    <Artifactid>Xxx</Artifactid>    <groupId>Xxx</groupId>    <version>Xxx</version></Dependency>

OK, this is OK. It did take a lot of time to read the information because it wasn't too familiar to Maven. In this record, one can leave a note, and hope to help people who meet the same problem.

Maven Add local jar Package

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.