maven之发布项目到nexus【clean deploy命令】(八)
2015-11-05 21:05
519 查看
当我们的项目开发完成以后,可能要进行发布(如果是独立的项目,就不需要发布啦,如果是模块项目,那么就要发布到nexus里,供其他开发人员下载调用。)
要想发布项目到nexus里,必须通过<distributionManagement>标签来进行配置。在之前的文章中有介绍nexus的工厂类别,其中提到两个:hosted里的Releases、Snapshots.
当我们发布项目到nexus里时,如果项目版本是x.x.x-Releases,则会发布到Releases工厂中;而项目版本是x.x.x-SNAPSHOTS则发布到Snapshots工厂中。
配置<distributionManagement>:
![](https://img-blog.csdn.net/20151105214617822)
代码:
![](https://img-blog.csdn.net/20151105215145322)
后面我们会看到如下的提示信息:
![](https://img-blog.csdn.net/20151105215216368)
怎么来设置授权呢?
![](https://img-blog.csdn.net/20151105222452477)
【1】:去到nexus管理界面 --- > 左侧菜单栏“Security” --> “Users” ,右侧所列出的用户中,只有deployment用户才有发布项目到nexus的权限。
【2】:在setting.xml里使用<server>标签进行授权。server里的id对应<distributionManagement>里设置的id。
流程是:当执行clean deploy命令进行发布时,首先会找到<distributionManagement>的配置,获取配置信息。
然后如果setting.xml里有配置server,对比id值,如果匹配的上,就验证server里的用户是否拥有发布的权限,有权限就把项目发布到对应的仓库里。
setting.xml中server标签代码:
如果我们不想把所有项目都发布到nexus的Releases或Snapshots仓库中,而是想在nexus里能为每个项目开辟一个空间,存放每个项目自己发布上去的依赖包。
要实现这种效果,需要以下几步操作:
(1)在nexus里为每个项目创建hosted类型的工厂(Releases或Snapshots两种)
![](https://img-blog.csdn.net/20151105225645353)
![](https://img-blog.csdn.net/20151105225659475)
![](https://img-blog.csdn.net/20151105230149768)
(2)在Securiy --> Privileges里添加Releases或Snapshots两种工厂的特权(可以执行那些操作,如往工厂里发布,查看,删除等特权)
![](https://img-blog.csdn.net/20151105230322226)
![](https://img-blog.csdn.net/20151105230331781)
![](https://img-blog.csdn.net/20151105230340057)
(3)在Security --> Roles 里添加角色,为角色配置权限
![](https://img-blog.csdn.net/20151105230559912)
![](https://img-blog.csdn.net/20151105230610179)
(4)在Security --> Users 里添加用户,为用户设定角色
![](https://img-blog.csdn.net/20151105230850081)
![](https://img-blog.csdn.net/20151105230902194)
(5)在pom.xml里的 <distributionManagement>把url改为对应的工厂路径,在setting里的server里设定对应的用户密码
![](https://img-blog.csdn.net/20151105231238792)
执行clean deploy命令后:
![](https://img-blog.csdn.net/20151105231459523)
要想发布项目到nexus里,必须通过<distributionManagement>标签来进行配置。在之前的文章中有介绍nexus的工厂类别,其中提到两个:hosted里的Releases、Snapshots.
当我们发布项目到nexus里时,如果项目版本是x.x.x-Releases,则会发布到Releases工厂中;而项目版本是x.x.x-SNAPSHOTS则发布到Snapshots工厂中。
配置<distributionManagement>:
代码:
<distributionManagement> <repository> <id>releasesId</id> <name>Releases name</name> <url>http://localhost:8081/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>snapshots id</id> <name>snapshots name</name> <url>http://localhost:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement>右键项目 --> run as ---> maven Build... --> 输入clean deploy命令(一开始会下载一些依赖包,淡定.....)。
后面我们会看到如下的提示信息:
怎么来设置授权呢?
【1】:去到nexus管理界面 --- > 左侧菜单栏“Security” --> “Users” ,右侧所列出的用户中,只有deployment用户才有发布项目到nexus的权限。
【2】:在setting.xml里使用<server>标签进行授权。server里的id对应<distributionManagement>里设置的id。
流程是:当执行clean deploy命令进行发布时,首先会找到<distributionManagement>的配置,获取配置信息。
然后如果setting.xml里有配置server,对比id值,如果匹配的上,就验证server里的用户是否拥有发布的权限,有权限就把项目发布到对应的仓库里。
setting.xml中server标签代码:
<server> <id>releasesId</id> <username>deployment</username> <password>deployment123</password> </server> <server> <id>snapshotsid</id> <username>deployment</username> <password>deployment123</password> </server>至此,发布的配置就完成了,执行clean deploy命令后,就会在nexus的Releases或Snapshots仓库中找到发布的项目了。
如果我们不想把所有项目都发布到nexus的Releases或Snapshots仓库中,而是想在nexus里能为每个项目开辟一个空间,存放每个项目自己发布上去的依赖包。
要实现这种效果,需要以下几步操作:
(1)在nexus里为每个项目创建hosted类型的工厂(Releases或Snapshots两种)
(2)在Securiy --> Privileges里添加Releases或Snapshots两种工厂的特权(可以执行那些操作,如往工厂里发布,查看,删除等特权)
(3)在Security --> Roles 里添加角色,为角色配置权限
(4)在Security --> Users 里添加用户,为用户设定角色
(5)在pom.xml里的 <distributionManagement>把url改为对应的工厂路径,在setting里的server里设定对应的用户密码
执行clean deploy命令后:
相关文章推荐
- hibernate中的PO持久化对象及PO三种状态
- nat表中各条chain的工作流程
- CSU 1538 暴力暴力暴力
- java final 关键字
- Template /template/ajax/head.ftl not found
- 简单抽奖
- 七周七种前端框架二: React 之概览
- sqlmap
- 【Android】多图选择器(支持图片预览 高效加载不怕OOM)
- Tip_对拍
- pylearn2 安装及测试 windows 7 64bit
- linux apache(httpd)编译安装和启动
- C# 中的结构体
- 懒加载
- TabControl控件中TabPage的显示和隐藏
- 函数式编程扫盲篇
- Android学习笔记之Intent穿梭于各个Activity之间
- 数值的整数次方(不考虑结果的大数问题)优秀的代码就是要注意细微的细节
- hdu2199 Can you solve this equation?
- 天声人語 20151105 篠原一さん逝く