maven推送本地jar到私服

本文介绍了如何使用Maven将本地jar包推送到私服仓库,包括部署到远程仓库的命令以及两个常见错误的处理方法,如缺少POM文件和部署权限问题。
摘要由CSDN通过智能技术生成

目录

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

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

三、常见错误

错误1:

错误2:


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

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

mvn deploy:deploy-file -DgroupId=com.fkp -DartifactId=http-client-test -Dversion=1.0-SNAPSHOT -Dpackaging=jar -Dfile=C:\Users\fengkunpeng\Desktop\http-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:\Users\fengkunpeng\Desktop\http-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:\Users\fengkunpeng\Desktop). 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>

  • 8
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值