用户工具

站点工具


分享:技术:nexus:nexus安装和介绍

nexus安装和介绍

nexus安装

Nexus提供了两种安装方式:

  1. 内嵌Jetty的捆绑包(bundle),要求:解压后即可单独运行,只要系统中安装了JRE
  2. WAR包:需要一个Servlet容器来运行,比如tomcat

这里演示在Ubuntu 14.04.2上安装bundle方式的nexus,版本号:2.11.1。

#安装jdk-1.7
  sudo apt-get install oracle-java7-installer
  java -version
#安装nexus
  cd /home/soft
  rz 选择 nexus-latest-bundle.zip
  unzip nexus-latest-bundle.zip
  cd /home/soft/nexus-2.11.1-01/bin
  sh nexus start #依赖jdk1.7 端口8081 

nexus介绍

浏览器中输入http://localhost:8081/nexus/ 在左侧输入框中输入spring,可以查询仓库中已经有的spring相关的包,可以点击右边的jar直接下载jar包,也可以在maven项目的pom.xml中加入右下角的依赖

<dependency>
  <groupId>org.springframework</groupId>
  <artifactId>spring-core</artifactId>
  <version>4.0.5.RELEASE</version>
</dependency>

点击左侧Repositories查看所有的子仓库,点击子仓库,底下Browse Index都可以查看该仓库中的jar包 点击右上角Log In,输入默认用户名:admin,密码:admin123登录

Public Repositories

公共的仓库,是一个仓库组,包含其他的子仓库,这个比较全,,从Repository Path可以看到http://121.43.104.34:8081/nexus/content/groups/public/,pom.xml配置nexus私有仓库时,url可以写上这个地址,就可以从这里下载maven依赖了。注意:如果该仓库中没有,nexus会先自己下载一份,再给客户端。

3rd party

第三方的仓库,比如开发项目依赖某些jar包从公共的maven仓库中下不到,就可以在这里手动上传

Releases

稳定版本库,如果项目版本号中不带SNAPSHOT都视为稳定版本,执行mvn deploy会发布到该库中

Snapshots

快照版本库,如果项目版本号中带SNAPSHOT都视为快照版本,执行mvn deploy会发布到该库中

maven项目使用nexus私有仓库

配置私服仓库

在pom.xml中配置nexus私服仓库,用于从nexus中下载maven依赖

<!-- 仓库配置 -->
<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>

配置版本发布管理

在pom.xml中配置版本发布管理,用于发布release稳定版本snapshots快照版本到nexus中。

<!-- 版本发布管理 -->
<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>

maven settings配置

由于nexus开发发布需要校验用户名和密码,所以maven deploy要发布成功,必须在maven的目录中修改apache-maven-3.0/conf/settings.xml,注意server标签中的id与repository标签中的id要一致,用户名密码即nexus中用户名密码

<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>

maven发布脚本

mvn clean deploy
分享/技术/nexus/nexus安装和介绍.txt · 最后更改: 2015/07/07 12:26 由 gxx