创建仓库
点击齿轮图标 -> Create repository。
创建快照版仓库
选择:maven2(hosted) -> 填写Name:xxx -> 选择Version policy:Snapshot -> 选择Deployment policy:Allow redeploy。
创建发布版仓库
选择:maven2(hosted) -> 填写Name:xxx -> 选择Version policy:Release -> 选择Deployment policy:Allow redeploy。
创建组,包含快照版和发布版
选择:maven2(group) -> 填写Name:xxx -> Member repositories把上边创建的两个仓库从左边移到右边 -> 点击:Create repository。
项目中的使用
代码地址:
部署jar包到私服
见nexus-deploy
模块。
- 在项目的pom.xml的project节点中添加内容
1
2
3
4
5
6
7
8
9
10
11
12
13
14<distributionManagement>
<!--私服部署地址-->
<repository>
<id>ciic-releases</id>
<name>releases</name>
<url>http://49.233.127.119:8666/repository/ciic-releases</url>
<uniqueVersion>true</uniqueVersion>
</repository>
<snapshotRepository>
<id>ciic-snapshots</id>
<name>snapshots</name>
<url>http://49.233.127.119:8666/repository/ciic-snapshots</url>
</snapshotRepository>
</distributionManagement> - 在Maven的settings.xml的servers节点中配置用户名密码
Idea自带的Maven:vi '/Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3/conf/settings.xml'
1
2
3
4
5
6
7
8
9
10
11<!--Nexus私服用户名密码-->
<server>
<id>ciic-snapshots</id>
<username>admin</username>
<password>xxx</password>
</server>
<server>
<id>ciic-releases</id>
<username>admin</username>
<password>xxx</password>
</server>
使用私服的jar包
见nexus-down
模块。
- 在项目的pom.xml的project节点中添加内容
1
2
3
4
5
6
7
8<repositories>
<!--私服下载地址-->
<repository>
<id>ciic-group</id>
<name>ciic-group</name>
<url>http://49.233.127.119:8666/repository/ciic-group/</url>
</repository>
</repositories>