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