maven如何推送本地jar到私服

后端 潘老师 5个月前 (12-06) 120 ℃ (0) 扫码查看

本文主要讲解关于maven推送本地jar到私服相关内容,让我们来一起了解下吧!

一、推送本地jar包到私服仓库

在任意存在pom文件的目录下运行cmd,执行以下命令。

mvn deploy:deploy-file -DgroupId=com.fkp -DartifactId=http-client-test -Dversion=1.0-SNAPSHOT -Dpackaging=jar -Dfile=C:UsersfengkunpengDesktophttp-client-test-1.0-SNAPSHOT.jar -Durl=http://192.168.200.10/nexus/content/repositories/snapshots/ -DrepositoryId=fkp-snapshots

-DgroupId:groupId

-DartifactId:artifactId

-Dversion:version

-Dpackaging:打包方式

-Dfile:文件绝对路径

-Durl:私服仓库地址,需时具体的宿主类型仓库

-DrepositoryId:仓库id,需要和settings.xml中server项中id一致

二、安装本地jar包到本地仓库

在任意存在pom文件的目录下运行cmd,执行以下命令。

mvn install:install-file -Dfile=C:UsersfengkunpengDesktophttp-client-test-1.0-SNAPSHOT.jar -DgroupId=com.fkp -DartifactId=http-client-test -Dversion=1.0-SNAPSHOT -Dpackaging=jar

-DgroupId:groupId

-DartifactId:artifactId

-Dversion:version

-Dpackaging:打包方式

-Dfile:文件绝对路径

三、常见错误

错误1:

[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (C:UsersfengkunpengDesktop). Please verify you invoked Maven from the correct directory. -> [Help 1]

处理:该错误可能发生在deploy和install中,在任意存在pom文件的目录下执行命令即可,随便找一个maven项目,在根目录下只运行cmd命令即可。

错误2:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (default-cli) on project http-client-test: Failed to deploy artifacts: Could not transfer artifact com.fkp:http-client-test:jar:1.0-20231203.074315-1 from/to Snapshots (http://192.168.200.10:8081/nexus/content/repositories/snapshots/): Failed to transfer file http://192.168.200.10:8081/nexus/content/repositories/snapshots/com/fkp/http-client-test/1.0-SNAPSHOT/http-client-test-1.0-20231203.074315-1.jar with status code 401 -> [Help 1]

处理:该错误可能发生在deploy中,检查命令中-DrepositoryId的值和maven配置文件settings.xml中server项下的id是否一致,且确保server下配置的用户和密码是否有权限访问私服。

以下是settings.xml中部分配置项。

    <servers>
        <server>
            <!--id需要和-DrepositoryId一致-->
            <id>fkp-snapshots</id>
            <username>fengkunpeng</username>
            <password>fkp123456</password>
        </server>
    </servers>

好啦,以上就是关于maven推送本地jar到私服相关的全部内容,希望对你有帮助。欢迎持续关注潘子夜个人博客(www.panziye.com),学习愉快哦!


版权声明:本站文章,如无说明,均为本站原创,转载请注明文章来源。如有侵权,请联系博主删除。
本文链接:https://www.panziye.com/back/12185.html
喜欢 (0)
请潘老师喝杯Coffee吧!】
分享 (0)
用户头像
发表我的评论
取消评论
表情 贴图 签到 代码

Hi,您需要填写昵称和邮箱!

  • 昵称【必填】
  • 邮箱【必填】
  • 网址【可选】