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
Step Two : Build a Ikanalyzer.jar Package-related pom.xml file that needs to be The Pom.xml defines its MAVEN coordinates and its corresponding dependency code, and the pom file is stored in the same folder as the jar file above, and the contents of the Ikanalyzer.jar coordinates and the Pom.xml file of the dependent code are 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> &L T;description>a dictionary and grammar-based Chinese segmenter</description> <dependencies> <d Ependency> <groupId>org.apache.lucene</groupId> <artifactid>lucene-core</art ifactid> <version>3.0.3</version> <optional>true</optional> </d ependency> <dependency> <groupId>org.apache.solr</groupId> <artifacti D>solr-core</artifactid> <version>1.4.1</version> <optional>true</optional> </dependency> < ;d ependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.2</version> <scope>test</scope> </dependency> & Lt;dependency> <groupId>org.apache.lucene</groupId> <artifactid>lucene-analyzer s</artifactid> <version>3.0.3</version> <scope>test</scope> < ;/dependency> <dependency> <groupId>org.apache.lucene</groupId> <arti Factid>lucene-smartcn</artifactid> <version>3.0.3</version> <SCOPE>TEST&L T;/scope> </dependency> </dependencies></project>
Step three : Open cmd, go to the Mylib folder, run the following command (do not wrap, with a space)
MVN install:install-file -dfile=ikanalyzer3.2.8.jar -dgroupid=org.wltea.ik-analyzer -DartifactId= Ik-analyzer -dversion=3.2.8 -dpackaging=jar
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:
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>
Do not rely on the jar to join the local warehouse sample:
The first step: Store the Tsp.common-1.0.jar package in a folder, such as the Tsp.common folder
Step Two: Build a Tsp.common-1.0.jar Package-relatedpom.xml file and need to be The Pom.xml defines its MAVEN coordinates and its corresponding dependency code, and the pom file is stored in the same folder as the jar file above, and the contents of the Tsp.common-1.0.jar coordinates and the Pom.xml file of the dependent code are 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>cn.xxxxx.tsp.common</groupId> <artifactId>tsp.common</artifactId> <version>1.0</version> <name> Tsp.common</name> <description></description></project>
Step three : Open cmd, go to the Tsp.comon folder, run the following command (do not wrap, with a space)
MVN Install:install-file-dfile=tsp.common-1.0.jar-dgroupid=cn.xxxxxxx.tsp.common-dartifactid=tsp.common- Dversion=1.0-dpackaging=jar
Join the success, and then to the local warehouse see the following:
Maven How to manually add dependent jar files to the local MAVEN repository