示例
E:\dev\maven\xinao\apache-maven-3.6.0\bin\mvn install:install-file -DgroupId=com.hikvision.ga -DartifactId=artemis-http-client -Dversion=1.1.8 -Dpackaging=jar -Dfile=E:\xinao\code\fanneng\Project_Project\lib\ygyg-bps-eventbus-client-1.0-RELEASE.jar
参数解释如下:
-DgroupId
: 指定groupId。-DartifactId
: 指定artifactId`。-Dversion
: 指定版本号。-Dpackaging
: 指定库的打包类型,通常是 jar
。-Dfile
: JAR 文件的路径。该命令会使用E:\dev\maven\xinao\apache-maven-3.6.0\bin\mvn路径下的settings.xml文件
如果要用指定的settings.xml需要通过-s指定
E:\dev\maven\xinao\apache-maven-3.6.0\bin\mvn install:install-file -s E:\dev\maven\public\apache-maven-3.6.0\conf\settings.xml -DgroupId=com.hikvision.ga -DartifactId=artemis-http-client -Dversion=1.1.8 -Dpackaging=jar -Dfile=E:\xinao\code\fanneng\Project_Project\lib\ygyg-bps-eventbus-client-1.0-RELEASE.jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom ---
[INFO] Installing E:\xinao\code\fanneng\Project_Project\lib\ygyg-bps-eventbus-client-1.0-RELEASE.jar to E:\repository\com\hikvision\ga\artemis-http-client\1.1.8\artemis-http-client-1.1.8.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.974 s
[INFO] Finished at: 2023-09-19T17:03:15+08:00
[INFO] ------------------------------------------------------------------------
E:\dev\maven\xinao\apache-maven-3.6.0里配置的本地库为:D:\Tools\maven_repository
E:\dev\maven\public\apache-maven-3.6.0\conf\settings.xml中配置的本地库为E:\repository
通过日志可以看到将E:\xinao\code\fanneng\Project_Project\lib\ygyg-bps-eventbus-client-1.0-RELEASE.jar 安装到了 E:\repository\com\hikvision\ga\artemis-http-client\1.1.8\artemis-http-client-1.1.8.jar