4、Nexus按项目类型分配不同的工厂来发布不同的项目

【3.发布Maven项目到nexus中】配置了把项目发布到nexus中的方法
但是有时候,一个公司会有很多项目[crm,oa,erp]等等的项目。如果把这些项目全部都放到releases或者snapshots中的话会有点混乱。
比较好的办法是,按项目来分。
每个项目一个工厂:cms-repositorie、oa-repositorie
每个项目一个角色:cms oa
每个角色都只管理自己的工厂:cms管理cms-repositorie…..
这样的好处就是,按项目类型来管理不同的项目,不同的开发人员的发布权限

例如:现在为cms这个项目配置工厂

1.添加工厂

首先添加一个:cms-releases的工厂
Views/Repositories—>Add—>HostedRepository
Repository Policy:选择Releases
Deployment Policy:选择Allow Deployment

同样的方法,再添加一个:cms-snapshots工厂
注意:选择Repository Policy为Snapshot

2.添加权限

为cms项目添加一个:增删改查的权限
默认情况下,nexus为新工厂分配了view权限

添加一个cms的releases的权限

然后再添加一个cms的snapshots的权限
注意:Repostory需要选择为snapshots类型的工厂
添加后的权限为:release和snapshots都有相应的增删改查

3.添加角色

4.添加用户

5.发布项目

至此,cms项目的release工厂和snapshots工厂都已经配置完成了。
在发布项目的时候,就可以使用该工厂了。
pom.xml中配置需要的工厂

 

1
2
3
4
5
6
7
8
9
10
11
12
13
< distributionManagement >
     <!-- 两个ID必须与 setting.xml中的<server></server>保持一致-->
     < repository >
         < id >cms-releases</ id >
         < name >Nexus Release Repository</ name >
     </ repository >
     < snapshotRepository >
         < id >cms-snapshots</ id >
         < name >Nexus Snapshot Repository</ name >
     </ snapshotRepository >
</ distributionManagement >

setting.xml文件中配置用户权限

 

1
2
3
4
5
6
7
8
9
10
< server
     < id >cms-releases</ id
     < username >cms</ username
     < password >cms123</ password
</ server
< server
     < id >cms-snapshots</ id
     < username >cms</ username
     < password >cms123</ password >  
< server >

使用命令发布项目 mvn:deploy

发布之后,就可以在cms snapshots repositories中看到刚才发布的项目

 

猜你喜欢

转载自blog.csdn.net/ziwuzhulin/article/details/80855924