Add your own development dependencies to the MAVEN local repository

Source: Internet
Author: User
Tags solr

Maven adds its own development dependency package to the Pom file, which is definitely not in the Maven repository (http://repo.maven.apache.org/maven2/). So how do we add packages that aren't in the MAVEN repository to the local maven repository? 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 Test folder
Step Two&NBSP: Build a Ikanalyzer.jar Package-related  pom .xml file, you need to define its MAVEN coordinates and its corresponding dependency code in Pom.xml, and also store the pom file in the same folder as the jar file above, Ikanalyzer.jar coordinates and dependency code as follows:

<project xmlns= "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> <depende Ncy> <groupId>org.apache.lucene</groupId> <artifactId>lucene-core</artifactId> & lt;version>3.0.3</version> <optional>true</optional> </dependency> <dependency&gt      ; <groupId>org.apache.solr</groupId> <artifactId>solr-core</artifactId> <version>1.4 .1</version> &LT;OPTIONAL&GT;TRUE&LT;/OPTIONAL&GT </dependency> <dependency> <groupId>junit</groupId> <artifactid>junit</artif actid> <version>3.8.2</version> <scope>test</scope> </dependency> &LT;DEP Endency> <groupId>org.apache.lucene</groupId> &LT;ARTIFACTID&GT;LUCENE-ANALYZERS&LT;/ARTIFACTID&G      T      <version>3.0.3</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.lucene</groupId> <artifactId>lucene-smartcn</artifactId> <versi on>3.0.3</version> <scope>test</scope> </dependency> </dependencies></project >

Step three : Open cmd, go to the Mylib folder, run the command below

E:\TEST&GT;MVN install:install-file-dfile= file name. jar-dgroupid= Organization name-dartifactid= project name-dversion= version number-Dpackaging=jar[INFO ] Scanning for projects ... [INFO] [INFO]------------------------------------------------------------------------[INFO] Building Maven Stub Project ( No POM) 1[info]------------------------------------------------------------------------[Info][info]--- Maven-install-plugin:2.4:install-file (DEFAULT-CLI) @ standalone-pom---downloading:https://repo.maven.apache.org/ maven2/org/codehaus/plexus/plexus-utils/3.0.5/plexus-utils-3.0.5.pomdownloaded:https://repo.maven.apache.org/ Maven2/org/codehaus/plexus/plexus-utils/3.0.5/plexus-utils-3.0.5.pom (3 KB at 0.4 kb/sec) downloading:https:// Repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-api/2.0.6/maven-plugin-api-2.0.6.jardownloading: Https://repo.maven.apache.org/maven2/org/apache/maven/maven-project/2.0.6/maven-project-2.0.6.jarDownloading: Https://repo.maven.apache.org/maven2/org/apache/maven/maven-settings/2.0.6/maven-settings-2.0.6.jardownloading:https://repo.maven.apache.org/maven2/org/apache/maven/maven-profile/2.0.6/ Maven-profile-2.0.6.jardownloading:https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-registry /2.0.6/maven-plugin-registry-2.0.6.jardownloaded:https://repo.maven.apache.org/maven2/org/apache/maven/ Maven-plugin-registry/2.0.6/maven-plugin-registry-2.0.6.jar (KB at 15.4 kb/sec) downloading:https:// repo.maven.apache.org/maven2/classworlds/classworlds/1.1-alpha-2/classworlds-1.1-alpha-2.jardownloaded:https:/ /repo.maven.apache.org/maven2/org/apache/maven/maven-profile/2.0.6/maven-profile-2.0.6.jar (+ KB at 10.3 KB/sec) downloading:https://repo.maven.apache.org/maven2/org/apache/maven/maven-model/2.0.6/ maven-model-2.0.6.jardownloaded:https://repo.maven.apache.org/maven2/org/apache/maven/maven-settings/2.0.6/ Maven-settings-2.0.6.jar (~ KB at 11.0 kb/sec) downloading:https://repo.maven.apache.org/maven2/org/apache/maven/ Maven-artifact-manager/2.0.6/maven-artifact-manager-2.0.6.jardownloaded:https://repo.maven.apache.org/maven2/org/apache/maven/maven-plugin-api/2.0.6/ Maven-plugin-api-2.0.6.jar (KB at 2.8 kb/sec) downloading:https://repo.maven.apache.org/maven2/org/apache/maven/ maven-repository-metadata/2.0.6/maven-repository-metadata-2.0.6.jardownloaded:https://repo.maven.apache.org/ Maven2/org/apache/maven/maven-repository-metadata/2.0.6/maven-repository-metadata-2.0.6.jar (at 3.3 KB/sec) downloading:https://repo.maven.apache.org/maven2/org/apache/maven/maven-artifact/2.0.6/ maven-artifact-2.0.6.jardownloaded:https://repo.maven.apache.org/maven2/classworlds/classworlds/1.1-alpha-2/ Classworlds-1.1-alpha-2.jar (Notoginseng KB at 5.0 kb/sec) downloading:https://repo.maven.apache.org/maven2/org/codehaus/ plexus/plexus-utils/3.0.5/plexus-utils-3.0.5.jardownloaded:https://repo.maven.apache.org/maven2/org/apache/ Maven/maven-artifact-manager/2.0.6/maven-artifact-manager-2.0.6.jar (at 6.4 kb/sec) downloaded:https:// repo.maven.apache.org/maven2/org/apache/maven/maven-model/2.0.6/maven-model-2.0.6.jar (Kbytes at 6.9 kb/sec) downloaded:https://repo.maven.apache.org /maven2/org/apache/maven/maven-artifact/2.0.6/maven-artifact-2.0.6.jar (KB at 5.7 kb/sec) downloaded:https:// Repo.maven.apache.org/maven2/org/apache/maven/maven-project/2.0.6/maven-project-2.0.6.jar (KB at 5.8 KB/sec) Downloaded:https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0.5/plexus-utils-3.0.5.jar ( 226 KB at 10.7 kb/sec) [INFO] Installing E:\test\ file name. jar to C:\Users\Administrator\.m2\repository\ organization name Project name \ version number \ filename. jar[ INFO] Installing C:\users\admini~1\appdata\local\temp\mvninstall1993617445439338455.pom to C:\Users\Administrator\ . m2\repository\ Organization name \ Project name \ version number \ filename. pom[info]---------------------------------------------------------------------- --[info] BUILD success[info]------------------------------------------------------------------------[INFO] Total time:30.436 S[info] finished at:2016-05-21t22:16:10+08:00[info] Final Memory:9m/183m[info] ------------------------------------------------------------------------ 

This allows you to install Ikanalyzer3.2.8.jar into the appropriate directory for your Maven local library folder. You can modify the setting values of the above parameters according to the actual situation of the package you need to install. You can then use the following dependencies in the Pom.xml file to introduce the above package into the project as follows:

<dependency><groupId>org.wltea</groupId><artifactId>IKAnalyzer</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><scope>system</scope>    <systempath>e:\test\ Ikanalyzer3.2.8.jar</systempath></dependency>

Add your own development dependencies to the MAVEN local 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.