Apache Maven is a software (especially Java software) project management and automatic building tool provided by the Apache Software Foundation. Based on the concept of the project Object Model (POM), Maven uses a central information segment to manage steps such as building, reporting, and documentation of a project. I used to be a subproject of the Jakarta project and is now an independent Apache project.
You must have met the idea of adding your own development dependency packages in the pom file, these packages are certainly not in the Maven repository (http://repo1.maven.org/maven2. So how can we add packages that do not exist in the Maven repository to the local Maven repository? Very simple. Here, the IKAnalyzer. jar package is used as an example.
Step 1: store the IKAnalyzer. jar package in a folder, such as the mylib folder.
Step 2: Create an IKAnalyzer. jar package-related pom. xml file, which must be in pom. define the maven coordinates and corresponding dependent code in xml, and store the pom file in the same folder as the jar file, IKAnalyzer. the jar coordinates and dependency 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>
<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 3: Open CMD, enter 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 \
-Dpackaging = jar
In this way, you can install IKAnalyzer3.2.8.jar to the corresponding directory of your Maven local library folder. You can modify the setting values of the preceding parameters based on the actual situation of the installation package. Then you can introduce the above package in the pom. xml file through the following dependencies in the project, as follows:
<Dependency>
<GroupId> org. wltea. ik-analyzer </groupId>
<ArtifactId> ik-analyzer </artifactId>
<Version> 3.2.8 </version>
</Dependency>
Of course, you may not release IKAnalyzer3.2.8.jar to your local Maven library, but introduce it through the following configuration. 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>
(End)
Maven details: click here
Maven: click here
Maven 3.1.0 release, Project Build Tool
Install Maven in Linux
Maven3.0 configuration and simple use
Set up sun-jdk and Maven2 in Ubuntu
Get started with Maven