Maven uses local jar files

http://www.bug315.com/article/513.htm

 

In project development, especially for individual developers, when using Maven for development, we sometimes need to use some jar files that do not exist in the Maven public library, but do not want to build a Nexus by yourself (***), because it is too troublesome . Then you can take a look at this article, let Maven use the local jar file.

 

Case:

Suppose we need to use a bug315-1.0.1.jar file in our current project, but there is no such jar file in the Maven repository, and we have not built nexus ourselves.

 

Solution:

Import the bug315-1.0.1.jar file into the local Maven repository, and then it can be used normally. The specific operation steps are as follows:

(1) Import the jar into the local warehouse

Use the mvn install:install-file command in the following format:

mvn install:install-file  -Dfile=jar文件  -DgroupId= -DartifactId= -Dversion=  -Dpackaging=

 

The specific commands are as follows:

mvn install:install-file -Dfile=bug315-1.0.1.jar -DgroupId=com.bug315 -DartifactId=bug315 -Dversion=1.0.1 -Dpackaging=jar

After the above file is successfully executed, you will see the following directory hierarchy in your Maven repository:

com\bug315\bug315\1.0.1\bug315-1.0.1.jar

 

Notice:

The content filled in each of the above options needs to be written according to your own jar file. If you don't know how to write it, go to Maven Basics! ! !

 

(2) Reference local jar

<dependency>

    <groupId>com.bug315</groupId>

    <artifactId>bug315</artifactId>

    <version>1.0.1</version>

</dependency>

This is the end of the explanation, I hope it can help you! !

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326357887&siteId=291194637