将Maven项目发布到Nexus私服

1.首先进入http://S1:8081/nexus/index.html 登录后,进入repositories页面。

2.点击Add按钮创建一个hosted repository,id为sheismylife,name为chenshu repository,点save按钮。创建成功。

3.如果有一个项目要发布,可以手动在网页上upload,也可通过mvn deploy命令部署。如果是后者:

修改pom.xml文件

 

[html] view plain copy print ?
 
  1. <distributionManagement>  
  2.   <repository>  
  3.     <id>sheismylife</id>  
  4.     <url>http://S1:8081/nexus/content/repositories/sheismylife</url>  
  5.   </repository>  
  6. </distributionManagement>  


4.在Nexus私服的网页上,找到Security->Users,找到deployment,右键点击后,选择set password,设置你的密码。

 

同时到chenshu repository中config页面,允许redeploy.

5.回到开发机器上,在~/.m2/settings.xml中加上一段配置

 

[html] view plain copy print ?
 
  1. <servers>  
  2.   <server>  
  3.     <id>sheismylife</id>  
  4.     <username>deployment</username>  
  5.     <password>your_pwd</password>  
  6.   </server>  
  7. </servers>  

 

 

123456就是第4步设置的密码。

注意,如果需要通过Jenkins部署的话,上面这段配置也需要加在Jenkins server的settings.xml文件中。

 

到这里,Nexus以及Maven的报错信息非常不友好。注意这里有几个基本要求:

1.repository的release模式要支持redeploy

2.settings.xml中的settings.servers.server.id和pom.xml中的distributionManagement.repository.id的值必须相等

3.deployment用户密码最好修改

4.要确保这个repository被加入到Public Repositories中。在Repositories列表中单选第一个Public Repositories后,下方会出现两个列表框,将位于右边的自己的repository拖拽到左边,然后保存即可。

如果一个细节弄错,比如我刚才少了一个servers,mvn竟然没有错误提示。

5.当实在找不出部署失败的原因时(mvn deploy给的出错信息通常不足),可以在Nexus私服网页上手动部署,经常能够得到明确的错误信息,便于解决问题。

6.注意,不要将snapshot版本部署在release仓库里面,你会失败的。修正方式最简单的是将pom.xml中的版本号改为1.0.

 

http://blog.csdn.net/csfreebird/article/details/7212124

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值