maven nexus deploy方式以及相关注意事项(增加eclipse执行maven deploy)

摘要:
总的来说,jar部署到nexus上有两种方式:1、直接登录nexus控制台进行上传,如下:但是,某些仓库可能被设置了禁止控制台上传,如下:这种情况下,只能通过mvn:deploy进行部署了。mvndeploy:deploy-file-DgroupId=com.ld.net.spider-DartifactId=com.ld.net.spider.ext-Dversion=1.0.0-SNAPSHOT-Dpackaging=jar-Dfile=C:新建文件夹com.ld.net.spider.ext-1.0.0-SNAPSHOT.jar-Durl=http://172.18.30.181:8081/nexus/content/repositories/snapshots-DrepositoryId=snapshots[INFO]Scanningforprojects...[INFO][INFO]------------------------------------------------------------------------[INFO]Buildingcom.ld.net.spider.parent1.0.0-SNAPSHOT[INFO]------------------------------------------------------------------------[INFO][INFO]---maven-deploy-plugin:2.7:deploy-file@com.ld.net.spider.parent---Downloading:http://xxx:8081/nexus/content/repositories/snapshots/com/ld/net/spider/com.ld.net.spider.ext/maven-metadata.xmlUploading:http://xxx:8081/nexus/content/repositories/snapshots/com/ld/net/spider/com.ld.net.spider.ext/1.0.0-SNAPSHOT/maven-metadata.xmlUploaded:http://xxx:8081/nexus/content/repositories/snapshots/com/ld/net/spider/com.ld.net.spider.ext/1.0.0-SNAPSHOT/maven-metadata.xmlUploading:http://xxx:8081/nexus/content/repositories/snapshots/com/ld/net/spider/com.ld.net.spider.ext/maven-metadata.xmlUploaded:http://xxx:8081/nexus/content/repositories/snapshots/com/ld/net/spider/com.ld.net.spider.ext/maven-metadata.xml[INFO]------------------------------------------------------------------------[INFO]BUILDSUCCESS[INFO]------------------------------------------------------------------------[INFO]Totaltime:1.028s[INFO]Finishedat:2016-09-27T18:32:32+08:00[INFO]FinalMemory:6M/16M[INFO]------------------------------------------------------------------------还需要一点注意的就是要部署的jar/pom不能位于本地仓库所在的目录:否则会出错,如下所示:[ERROR]Failedtoexecutegoalorg.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-fileonprojectcom.ld.net.spider.parent:Cannotdeployartifactfromthelocalrepository:C:apache-maven-3.3.9epocomldetspidercom.ld.net.spider.parent1.0.0-SNAPSHOTcom.ld.net.spider.parent-1.0.0-SNAPSHOT.pom-˃[Help1]注意上述事项后,应该是没有问题的。完整的mvndeploy使用指南见http://maven.apache.org/plugins/maven-deploy-plugin/usage.html。常见错误[ERROR]Failedtoexecutegoalorg.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-fileonprojectstandalone-pom:Failedtodeployartifacts:Couldnotfindartifactcom.ld.net.spider:com.ld.net.spider:jar:1.0.1-20161008.032827-1insnapshots-˃[Help1]仓库http://172.18.30.181:8081/nexus/content/groups/snapshots所指向的地址不存在。eclispe执行mavendeploy部署到远程仓库m2eclipse默认没有提供mavendeploy选项,

以前公司都是配管负责管理jar的,现在没有专职配管了,得自己部署到deploy上供使用。总的来说,jar部署到nexus上有两种方式:

1、直接登录nexus控制台进行上传,如下:

maven nexus deploy方式以及相关注意事项(增加eclipse执行maven deploy)第1张

但是,某些仓库可能被设置了禁止控制台上传,如下:

maven nexus deploy方式以及相关注意事项(增加eclipse执行maven deploy)第2张

这种情况下,只能通过mvn:deploy进行部署了。

2、命令行方式上传。使用mvn:deploy部署前需要在settings.xml中配置server节点,指定仓库编号和用户名密码,如下所示:

<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>

这里的id应该需要和命令行中的repositoryId相同,否则会报401没有权限。

mvn deploy:deploy-file -DgroupId=com.ld.net.spider -DartifactId=com.ld.net.spider.ext -Dversion=1.0.0-SNAPSHOT -Dpackaging=jar -Dfile=C:新建文件夹com.ld.net.spider.ext-1.0.0-SNAPSHOT.jar -Durl=http://172.18.30.181:8081/nexus/content/repositories/snapshots -DrepositoryId=snapshots
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building com.ld.net.spider.parent 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy-file (default-cli) @ com.ld.net.spider.parent ---
Downloading: http://xxx:8081/nexus/content/repositories/snapshots/com/ld/net/spider/com.ld.net.spider.ext/maven-metadata.xml
Uploading: http://xxx:8081/nexus/content/repositories/snapshots/com/ld/net/spider/com.ld.net.spider.ext/1.0.0-SNAPSHOT/maven-metadata.xml
Uploaded: http://xxx:8081/nexus/content/repositories/snapshots/com/ld/net/spider/com.ld.net.spider.ext/1.0.0-SNAPSHOT/maven-metadata.xml (788 B at 26.5 KB/sec)
Uploading: http://xxx:8081/nexus/content/repositories/snapshots/com/ld/net/spider/com.ld.net.spider.ext/maven-metadata.xml
Uploaded: http://xxx:8081/nexus/content/repositories/snapshots/com/ld/net/spider/com.ld.net.spider.ext/maven-metadata.xml (298 B at 10.8 KB/sec)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.028 s
[INFO] Finished at: 2016-09-27T18:32:32+08:00
[INFO] Final Memory: 6M/16M
[INFO] ------------------------------------------------------------------------

还需要一点注意的就是要部署的jar/pom不能位于本地仓库所在的目录:否则会出错,如下所示:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (default-cli) on project com.ld.net.spider.parent: Cannot deploy artifact from the local repository: C:apache-maven-3.3.9 epocomld etspidercom.ld.net.spider.parent1.0.0-SNAPSHOTcom.ld.net.spider.parent-1.0.0-SNAPSHOT.pom -> [Help 1]

注意上述事项后,应该是没有问题的。

完整的mvn deploy使用指南见http://maven.apache.org/plugins/maven-deploy-plugin/usage.html。

常见错误

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (default-cli) on project standalone-pom: Failed to deploy artifacts: Could not find artifact com.ld.net.spider:com.ld.net.spider:jar:1.0.1-20161008.032827-1 in snapshots (http://172.18.30.181:8081/nexus/content/groups/snapshots) -> [Help 1]

仓库http://172.18.30.181:8081/nexus/content/groups/snapshots所指向的地址不存在。

maven settings.xml的完整配置可参考http://maven.apache.org/settings.html,pom.xml的完整配置可参考https://maven.apache.org/pom.html。

eclispe执行maven deploy部署到远程仓库

m2eclipse默认没有提供maven deploy选项,需要自己build...,如下:

maven nexus deploy方式以及相关注意事项(增加eclipse执行maven deploy)第3张

maven nexus deploy方式以及相关注意事项(增加eclipse执行maven deploy)第4张

maven nexus deploy方式以及相关注意事项(增加eclipse执行maven deploy)第5张

这样的话,source/jar/pom就都更新上去了。

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project *: Failed to deploy artifacts: Could not transfer artifact *:jar:1.0 from/to releases (http://10.1.81.199:8081/nexus/content/repositories/releases/): Failed to transfer file:http://10.1.81.199:8081/nexus/content/repositories/releases/com/cs2c/security-management-client*/1.0/*-1.0.jar. Return code is: 401, ReasonPhrase:Unauthorized.

原因是没有配置认证,比如缺少snapshots。maven目录conf的setting.xml里,

  1. <server>
  2. <id>releases</id>
  3. <username>admin</username>
  4. <password>admin123</password>
  5. </server>
  6. <server>
  7. <id>snapshots</id>
  8. <username>admin</username>
  9. <password>admin123</password>
  10. </server>
  11. </servers>

用户名和密码都是nexus的。再次deploy即可。

注意这里的id要和pom.xml里远程deploy的地址对应一致,我的pom.xml里配置:

  1. <!--配置远程发布到私服,mvndeploy-->
  2. <distributionManagement>
  3. <repository>
  4. <id>releases</id>
  5. <name>NexusReleaseRepository</name>
  6. <url>http://10.1.81.199:8081/nexus/content/repositories/releases/</url>
  7. </repository>
  8. <snapshotRepository>
  9. <id>snapshots</id>
  10. <name>NexusSnapshotRepository</name>
  11. <url>http://10.1.81.199:8081/nexus/content/repositories/snapshots/</url>
  12. </snapshotRepository>
  13. </distributionManagement>

免责声明:文章转载自《maven nexus deploy方式以及相关注意事项(增加eclipse执行maven deploy)》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇CentOS ISO版本区别koa 上传图片,上传文件,批量上传文件,批量上传图片...下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Android 7.0正式版工厂镜像下载

Android 7.0正式版工厂镜像下载 从3月份上线首个开发者预览版(Developer Preview)之后,经过近6个月时间的打磨,谷歌今天开始向Nexus设备推送Android 7.0 Nougat牛轧糖正式版(Final Builds)。可通过OTA渠道升级的设备有:Nexus 6, Nexus 5X, Nexus 6P, Nexus 9, N...

NEXUS S安卓4.0/4.1 【完美】 ROOT教程

原文链接:http://bbs.gfan.com/android-3517082-1-1.html 进行bootloader解锁(即使解锁,再上锁),会清除你手机上的【所有】数据(包括内部的16G SD 存储),包括但不限于应用、设置、联系人和账户等,请做好数据备份!·理论上对各种版本、各种机型的ROM都可以获取ROOT权限。·关于Busybox,麻烦各位...

用Nexus做Maven私服全攻略

Nexus简介 Nexus是Sonatype推出的强大Maven仓库管理器产品,要比以前TSS上介绍的Artifactory要好使用的多,也是一个拆箱即用的Java App,内嵌Jetty容器和Java Wrapper做Windows服务,安装简单到解压然后双击install即可。更详细的帮助手册请上官方网站查看,这里推荐一个翻译中的书籍——《Maven权...

快使用阿里云的maven仓库

自从开源中国的maven仓库挂了之后就一直在用国外的仓库,慢得想要砸电脑的心都有了。如果你和我一样受够了国外maven仓库的龟速下载?快试试阿里云提供的maven仓库,从此不在浪费生命…… 仓库地址:http://maven.aliyun.com/nexus/#view-repositories;public~browsestorage 仓库配置 在mav...

maven&amp;amp;nexus_repository 私库搭建与使用

一、nexus仓库安装 1,http://www.sonatype.org/nexus/    下载sso版本,免费2,tar -zxvf nexus-2.11.1-01-bundle.tar.gz3,修改端口号    /conf/nexus.properties文件     application-port属性值设置端口号4,默认端口8081,http:...

树莓派搭建Nexus2私服

使用树莓派搭建Nexus2私服需要的材料有: 树莓派3B+(或者4B) 移动硬盘一个 树莓派相关文章: 树莓派搭建nexus2.x私服(本文) 树莓派搭建视频监控平台 树莓派视频监控平台实现录制归档 树莓派实现人脸打卡机 1. 下载nexus2.x安装包 由于nexus2.x官方的启动环境并不支持arm架构的树莓派,所以这里采用tomcat7 +...