Package non-Maven managed jars into the MAVEN local repository

Source: Internet
Author: User

There are 2 cases where you need to issue the MAVEN command manually including a jar to Maven's local repository.

    1. The jar to be used does not exist in the central repository of Maven.
    2. 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:\&GT;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.

Package non-Maven managed jars into 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.