这里会显示出您选择的修订版和当前版本之间的差别。
两侧同时换到之前的修订记录 前一修订版 后一修订版 | 前一修订版 | ||
分享:技术:nexus:nexus安装和介绍 [2015/07/07 11:24] gxx |
分享:技术:nexus:nexus安装和介绍 [2015/07/07 12:26] (当前版本) gxx [maven发布脚本] |
||
---|---|---|---|
行 34: | 行 34: | ||
{{ :分享:技术:nexus:nexus截图4.png?300 |}} | {{ :分享:技术:nexus:nexus截图4.png?300 |}} | ||
- | **介绍几个子仓库** | + | ==== Public Repositories ==== |
- | **Public Repositories** | + | |
公共的仓库,是一个仓库组,包含其他的子仓库,这个比较全,,从Repository Path可以看到http://121.43.104.34:8081/nexus/content/groups/public/,pom.xml配置nexus私有仓库时,url可以写上这个地址,就可以从这里下载maven依赖了。注意:如果该仓库中没有,nexus会先自己下载一份,再给客户端。 | 公共的仓库,是一个仓库组,包含其他的子仓库,这个比较全,,从Repository Path可以看到http://121.43.104.34:8081/nexus/content/groups/public/,pom.xml配置nexus私有仓库时,url可以写上这个地址,就可以从这里下载maven依赖了。注意:如果该仓库中没有,nexus会先自己下载一份,再给客户端。 | ||
{{ :分享:技术:nexus:nexus截图5.png?300 |}} | {{ :分享:技术:nexus:nexus截图5.png?300 |}} | ||
- | **3rd party** | + | ==== 3rd party ==== |
第三方的仓库,比如开发项目依赖某些jar包从公共的maven仓库中下不到,就可以在这里手动上传 | 第三方的仓库,比如开发项目依赖某些jar包从公共的maven仓库中下不到,就可以在这里手动上传 | ||
{{ :分享:技术:nexus:nexus截图6.png?300 |}} | {{ :分享:技术:nexus:nexus截图6.png?300 |}} | ||
- | **Releases** | + | ==== Releases ==== |
稳定版本库,如果项目版本号中不带SNAPSHOT都视为稳定版本,执行mvn deploy会发布到该库中 | 稳定版本库,如果项目版本号中不带SNAPSHOT都视为稳定版本,执行mvn deploy会发布到该库中 | ||
{{ :分享:技术:nexus:nexus截图7.png?300 |}} | {{ :分享:技术:nexus:nexus截图7.png?300 |}} | ||
- | **Snapshots** | + | ==== Snapshots ==== |
快照版本库,如果项目版本号中带SNAPSHOT都视为快照版本,执行mvn deploy会发布到该库中 | 快照版本库,如果项目版本号中带SNAPSHOT都视为快照版本,执行mvn deploy会发布到该库中 | ||
{{ :分享:技术:nexus:nexus截图8.png?300 |}} | {{ :分享:技术:nexus:nexus截图8.png?300 |}} | ||
+ | ===== maven项目使用nexus私有仓库 ===== | ||
+ | ==== 配置私服仓库 ==== | ||
+ | 在pom.xml中配置nexus私服仓库,用于从nexus中下载maven依赖 | ||
+ | <code xml> | ||
+ | <!-- 仓库配置 --> | ||
+ | <repositories> | ||
+ | <!-- nexus私服仓库 --> | ||
+ | <repository> | ||
+ | <id>nexus</id> | ||
+ | <name>Team Nexus Repository</name> | ||
+ | <url>http://121.43.104.34:8081/nexus/content/groups/public</url> | ||
+ | </repository> | ||
+ | </repositories> | ||
+ | </code> | ||
+ | ==== 配置版本发布管理 ==== | ||
+ | 在pom.xml中配置版本发布管理,用于发布**release稳定版本**和**snapshots快照版本**到nexus中。 | ||
+ | <code xml> | ||
+ | <!-- 版本发布管理 --> | ||
+ | <distributionManagement> | ||
+ | <!-- release稳定版本 --> | ||
+ | <repository> | ||
+ | <id>nexus-releases</id> | ||
+ | <name>Nexus Release Repository</name> | ||
+ | <url>http://121.43.104.34:8081/nexus/content/repositories/releases/</url> | ||
+ | </repository> | ||
+ | <!-- snapshots快照版本 --> | ||
+ | <snapshotRepository> | ||
+ | <id>nexus-snapshots</id> | ||
+ | <name>Nexus Snapshot Repository</name> | ||
+ | <url>http://121.43.104.34:8081/nexus/content/repositories/snapshots/</url> | ||
+ | </snapshotRepository> | ||
+ | </distributionManagement> | ||
+ | </code> | ||
+ | ==== maven settings配置 ==== | ||
+ | 由于nexus开发发布需要校验用户名和密码,所以maven deploy要发布成功,必须在maven的目录中修改apache-maven-3.0/conf/settings.xml,注意server标签中的id与repository标签中的id要一致,用户名密码即nexus中用户名密码 | ||
+ | <code xml> | ||
+ | <servers> | ||
+ | <server> | ||
+ | <id>nexus-releases</id> | ||
+ | <username>admin</username> | ||
+ | <password>admin123</password> | ||
+ | </server> | ||
+ | <server> | ||
+ | <id>nexus-snapshots</id> | ||
+ | <username>admin</username> | ||
+ | <password>admin123</password> | ||
+ | </server> | ||
+ | </servers> | ||
+ | </code> | ||
+ | ==== maven发布脚本 ==== | ||
+ | <code> | ||
+ | mvn clean deploy | ||
+ | </code> |