Maven How to manually add jar packages to the local MAVEN repository

Source: Internet
Author: User
Tags solr

Apache Maven is a software (especially Java software) project management and automated build tool, provided by the Apache Software Foundation. Based on the concept of the Project object Model (abbreviated: POM), Maven uses a central piece of information to manage the steps of building, reporting, and documenting a project. Formerly a sub-project of the Jakarta Project, it is now a standalone Apache project.

You must have encountered a dependency package that you would like to add to your pom file, which is definitely not in the Maven repository (http://repo1.maven.org/maven2/). So how do we add the packages that don't exist in the MAVEN repository to the local maven library? Very simple. Here is an example of the Ikanalyzer.jar package.

The first step: Store the Ikanalyzer.jar package in a folder, such as the Mylib folder

The second step: to build a Ikanalyzer.jar package related to the Pom.xml file, you need to define their MAVEN coordinates and their corresponding dependency code in the Pom.xml file, and also store the pom file in the same folder as the above jar file, the Ikanalyzer.jar coordinates and the dependency code are as follows:

<Projectxmlns= "http://maven.apache.org/POM/4.0.0"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">    <modelversion>4.0.0</modelversion>    <groupId>Org.wltea.ik-analyzer</groupId>    <Artifactid>Ik-analyzer</Artifactid>    <version>3.2.8</version>    <name>IK Analyzer 3</name>    <Description>A dictionary and grammar-based Chinese segmenter</Description>    <Dependencies>        <Dependency>            <groupId>Org.apache.lucene</groupId>            <Artifactid>Lucene-core</Artifactid>            <version>3.0.3</version>            <Optional>True</Optional>        </Dependency>        <Dependency>            <groupId>Org.apache.solr</groupId>            <Artifactid>Solr-core</Artifactid>            <version>1.4.1</version>            <Optional>True</Optional>        </Dependency>        <Dependency>            <groupId>Junit</groupId>            <Artifactid>Junit</Artifactid>            <version>3.8.2</version>            <Scope>Test</Scope>        </Dependency>        <Dependency>            <groupId>Org.apache.lucene</groupId>            <Artifactid>Lucene-analyzers</Artifactid>            <version>3.0.3</version>            <Scope>Test</Scope>        </Dependency>        <Dependency>            <groupId>Org.apache.lucene</groupId>            <Artifactid>Lucene-smartcn</Artifactid>            <version>3.0.3</version>            <Scope>Test</Scope>        </Dependency>    </Dependencies></Project>

Step three: Open cmd and go to the Mylib folder and run the following command:

MVN install:install-file                   -dfile=ikanalyzer3.2.8.jar             -dgroupid=org.wltea.ik-analyzer        -DartifactId= Ik-analyzer               -dversion=3.2.8                        

This way you can install the Ikanalyzer3.2.8.jar into your local maven repository, and you can modify the parameters according to your situation. You can then introduce a custom jar package in your project from the following dependencies in the Pom.xml file, as follows:

<Dependency>     <groupId>Org.wltea.ik-analyzer</groupId>     <Artifactid>Ik-analyzer</Artifactid>     <version>3.2.8</version> </Dependency>

Of course, you can also not publish Ikanalyzer3.2.8.jar to your local maven library, but through the following configuration introduced, the effect is similar to the above:

<Dependency>    <groupId>Org.wltea</groupId>    <Artifactid>Ikanalyzer</Artifactid>    <version>3.2.8</version>    <Systempath>C:\Users\yangping\Desktop\a\IKAnalyzer3.2.8.jar</Systempath></Dependency>

Maven How to manually add jar packages to the local MAVEN repository

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.