There are 2 cases where you need to issue the MAVEN command manually including a jar to Maven's local repository.
- The jar to be used does not exist in the central repository of Maven.
- You have created a custom jar, and another Maven project needs to be used.
PS, or there are many jars that do not support Maven.
Case study
For example, Kaptcha, which is a popular third-party Java library, is used to generate "captcha" images to block spam, but it is not in Maven's central repository.
In this tutorial, we'll show you how to install the "Kaptcha" jar into Maven's local repository.
1. MVN Installation
Download "Kaptcha", unzip it and copy the Kaptcha-version.jar to another place, such as: C drive. Issue the following command:
MVN install:install-file-dfile=c:\kaptcha-{version}.jar-dgroupid=com.google.code-dartifactid=kaptcha-dversion={ Version}-dpackaging=jar
Example:
D:\>MVN install:install-file-dfile=c:\kaptcha-2.3.jar-dgroupid=com.google.code-dartifactid=kaptcha-dversion= 2.3-dpackaging=jar[info] Scanning for projects ... [INFO] Searching repository for plugin with prefix: ' Install '. [INFO]------------------------------------------------------------------------[INFO] Building Maven Default Project[info] Task-segment: [Install:install-file] (Aggregator-style) [INFO]-------------------------------------- ----------------------------------[INFO] [install:install-file][info] installing C:\kaptcha-2.3.jar to D:\maven_ Repo\com\google\code\kaptcha\2.3\kaptcha-2.3.jar[info]-------------------------------------------------------- ----------------[INFO] BUILD Successful[info]------------------------------------------------------------------- -----[INFO] Total time: < 1 Second[info] finished at:tue may 13:41:42 SGT 2014[info] Final Memory:3m/6m[info]---- --------------------------------------------------------------------
Now, the "Kaptcha" jar is copied to the Maven local repository.
2. Pom.xml
After the installation is complete, declare the coordinates of Kaptcha in Pom.xml.
<dependency> <groupId>com.google.code</groupId> <artifactid>kaptcha</ artifactid> <version>2.3</version> </dependency>
3. Complete
Build it, and now the "Kaptcha" jar can be retrieved from your Maven local repository.
Reference
- MAVEN Installation Documentation
- Kaptcha website
Tags: custom library Maven Local repository
This site is reproduced in addition to the article, are the original site or compiled
Welcome any form of reprint, but please be sure to indicate the source, respect for the work of others to create excellent examples of the tutorial
Reprint Please specify: Article reprinted from: http://www.yiibai.com/maven/include-library-manully-into-maven-local-repository.html
Maven Learning---Custom library to maven local repository