Maven manually copy the jar package in repository

Source: Internet
Author: User

For MAVEN projects, most third-party Java library files that are used on a daily basis can be downloaded automatically from MAVEN's central repository, but if the jar file we need is not in central repository, Then we need to manually add our own downloaded jar file to Maven's local reposotory, and we need to provide MAVEN with information to identify the jar file (possibly multiple), GroupID, Artifactid, and version.
I'm not going to tell you how to add a downloaded jar library to the local repository, we'll build ourselves a jar library, for example we have one of the simplest HelloWorld class Helloworld.java:

Package Com.thoughtworks.davenkin;

public class HelloWorld
{
public void SayHello ()
{
System.out.println ("Hello, World");
}
}

We want to package Helloworld.java as a jar file to be installed in MAVEN's local repository for other programs to use.
After compiling the package Hello-world.jar, in order to conform to the requirements of MAVEN, need to give Hello-world.jar a version number, so Hello-world.jar renamed to Hello-world-1.0.jar, then you can use MVN to install this package to Maven Lo Cal repository:
MVN install:install-file-dfile=path/to/hello-world-1.0.jar-dgroupid=com.thoughtworks.davenkin-dartifactid= Hello-world-dversion=1.0-dpackaging=jar

Where the-dfile option should give you the path to install the jar file, under Linux/mac, the jar file will be installed in the following directory:
~/.m2/repository/com/thoughtworks/davenkin/hello-world/1.0/hello-world-1.0.jar

Maven manually copy the jar package in 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.