As we all know, as long as we configure in the Pom.xml file, maven will automatically download the jar package to the local repository, so if we write a jar ourselves, then we cannot refer to this package by configuration, we need to manually install the package into the warehouse.
We use the command mvn install:install-file-dfile=your-jar-file-path-dgroupid=com.your.group-dartifactid=your-artifactid -dversion=x.x-dpackaging=jar installing the jar in Doc
-dfile: Indicates where the jar package needs to be installed
-dgroupid: Indicates GroupID
-dartifactid: Indicates artifactid
-dversion: Specify version
The above three parameters corresponding to the three parameters in the Pom file configuration, the corresponding, the Pom file is as follows:
<dependency> <groupId>alipay</groupId> <artifactId>alipay</artifactId> <version >1.0.0</version></dependency>
When we execute this command, remember to be in the same path as the Pom file, otherwise the following error will be reported (cannot find the pom file):
[Info] scanning for projects ... [INFO] [info] ------------------------------------------------------------------------[info] building maven stub project (no pom) 1[INFO] -------------------------------------------- ----------------------------[info][info] --- maven-install-plugin:2.4:install-file (default-cli ) @ standalone-pom ---[error] the specified file ' C:\Users\user\ Your-jar-file-path ' not exists[INFO] ---------------------------------------------------------- --------------[info] build failure[info] ------------------------------------------------------ ------------------[info] total time: 1.363 s[info] finished at: 2017-08-07t21:09:17+08:00[info] final memory: 6m/63m[info] ------------------------------- -----------------------------------------[Error] failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install-file (DEFAULT-CLI) on project standalone-pom: The specified file ' C:\Users\user\your-jar-file-path ' not Exists -> [help 1][error][error] to see the full stack trace of the errors, re-run maven with the -e switch. [error] re-run maven using the -x switch to enable full Debug logging. [ERROR] [error] for more information about the errors and possible solutions, please read the following articles:[error] [help 1] http:// Cwiki.apache.org/confluence/display/maven/mojofailureexception
Execution succeeds when we enter the Pom file path:
[Info] scanning for projects ... [WARNING] [Warning] some problems were encountered while building the effective model for com.ai.ecs:ics-web:war:0.0.1[WARNING] ' Build.plugins.plugin. (Groupid:artifactid) ' must be unique but found duplicate declaration Of plugin org.mortbay.jetty:jetty-maven-plugin @ com.ai.ecs:ics-web:[unknown-version], &NBSP;C:\YX\NANJINGSVN (1) \src\echannel\trunk\web\ics-web\pom.xml, line 204, column 13[ warning][warning] it is highly recommended to fix these problems Because they threaten the stability of your build. [WARNING] [Warning] for this reason, future maven versions might no longer support building such malformed projects. [WARNING] [INFO] [info] ------------------------------------------------------------------------[Info] building ics-web 0.0.1[info] ------------------------------------------------------------------------[info][info] --- maven-install-plugin:2.4:install-file (DEFAULT-CLI) @ ics-web ---[info] installing d:\my-jar\alipay-sdk-java20170307171631.jar to c:\users\user\m2\repository\com\your\group\ Your-artifactid\0.0.0\your-artifactid-0.0.0.jar[info] installing c:\users\user\appdata\local\temp\ mvninstall959507239612006886.pom to c:\users\user\m2\repository\com\your\group\your-artifactid\0.0.0 \your-artifactid-0.0.0.pom[info] ------------------------------------------------------------------------ [info] build success[info] -------------------------------------------------------------------- ----[info] total time: 2.396 s[info] finished at: 2017-08-07t21:12:48+08:00 [Info] final memory: 9m/108m[info] ------------------------------------------------------------------------
After the installation we open the local repository and we will see that we have created our own file path, and then we add the dependency in the Pom file OK.
How to manually install jar packages into a warehouse in Maven and problems