MAVEN imports the jar package to the local warehouse

Source: Internet
Author: User

Tutorial One:

For jar packages that are not on the official website, MAVEN imports the jar package to the local repository with the following command

Java code
    1. MVN Install:install-file
    2. -dgroupid= Package Name
    3. -dartifactid= Project Name
    4. -dversion= Version number
    5. -dpackaging=jar
    6. -dfile=jar file path


Take pinyin4j-2.5.0 as an example:

1. Place the Pinyin4j-2.5.0.jar file in the "D:\JAR_LIB" directory (any of the directories)

2. Execute the command:

MVN install:install-file-dfile=d:\jar_lib\pinyin4j-2.5.0.jar-dgroupid=net.sourceforge.pinyin4j-dartifactid= Pinyin4j-dversion=2.5.0-dpackaging=jar-dgeneratepom=true-dcreatechecksum=true

This makes it successful for Maven to import the Pinyin4j-2.5.0.jar package into the local repository.

3.pom.xml file configuration:

XML code
  1. <dependency>
  2. <groupId>net.sourceforge.pinyin4j</groupId>
  3. <artifactid>pinyin4j</artifactid>
  4. <version>2.5.0</version>
  5. </dependency>

Tutorial Two:

Sometimes, you project'll has dependency on a jar which are not in official maven repository , and maybe it is propriety jar file which would never be part of maven repository . In this case, you had to put it to your localrepository your the dependency.

There is a-install plug in to doing this job, which are something like:

Java code
    1. mvn install:install-file
    2. -dgroupid=<your_group_name>
    3. -dartifactid=<your_artifact_name>
    4. -dversion=<snapshot>
    5. -dfile=<path_to_your_jar_file>
    6. -dpackaging=jar
    7. -dgeneratepom=true

 

For example, your want to install the Danga ' s memcached client plugin, you can do:

This would add the Memcache jar into your local Maven2 repository under GroupId Com.danga and Artifactid memcached, You can then edit the your pom.xml adding this dependency.

However, the maven Eclipse can not recognize it since it always search from public repository

MAVEN imports the jar package to the local warehouse

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.