Nexus私服安装与配置

作者:jiangzz 电话:15652034180 微信:jiangzz_wx 微信公众账号:jiangzz_wy

nexus安装

下载nexus-2.12.0-01-bundle.zip

链接:https://pan.baidu.com/s/1Z3AGvwUFKUBYcFpRV5FEJQ 提取码:mees

将下载的文件解压

在这里插入图片描述
本案例小编是讲安装包解压在C:\Program Files\nexus目录下,进入C:\Program Files\nexus\nexus-2.12.0-01\bin\jsw\windows-x86-64,分别点击install-nexus.batstart-nexus.bat
在这里插入图片描述
至此为止Windows上Nexus的Maven私服安装成功,用户可以打开浏览器访问http://localhost:8081/nexus 查看
在这里插入图片描述

Maven 对接私服

配置setting.xml文件

servers标签

<server>
     <id>nexus</id>
     <username>admin</username>
     <password>admin123</password>
</server>

这是nexus 私服的默认管理账号,用户可以通过该账号管理Maven私服的仓库。

profies标签

配置Maven的私有仓库,这样在每次Maven工程下载依赖的时候都会尝试从私服下载,Maven的私服就相当于一个代理服务器。

<profies>
   <!--添加Maven私服-->
	<profile>     
		<id>profile1</id>
		<repositories>
		   <repository>     
			   <id>repo1-maven-central</id>     
			   <name>repo1 maven</name>     
			   <url>http://localhost:8081/nexus/content/groups/public</url>     
			   <releases>     
					<enabled>true</enabled>     
			   </releases>     
			   <snapshots>     
					<enabled>false</enabled>     
			   </snapshots>    
		   </repository>
		</repositories> 
		<pluginRepositories>
			<pluginRepository>          
				<id>central</id>
				 <url>http://localhost:8081/nexus/content/groups/public</url>
				 <releases>
					<enabled>true</enabled>
				 </releases>
				<snapshots>
					<enabled>true</enabled>
				</snapshots>
			</pluginRepository>
		</pluginRepositories>
	</profile>
	<!--激活当前私服-->
	<activeProfiles>
		<activeProfile>profile1</activeProfile>
	</activeProfiles>
</profies>

Jar包部署

用户可以在任意一个Maven项目pom.xml中添加如下配置:

<distributionManagement>
    <!--release 包部署仓库-->
	<repository>
		<id>nexus</id>
		<name>admin</name>
		<url>http://localhost:8081/nexus/content/repositories/releases/</url>
	</repository>
	<!--snapshot 部署仓库-->
	<snapshotRepository>
		<id>nexus</id>
		<name>admin</name>
		<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
	</snapshotRepository>
</distributionManagement>

然后执行:mvn deploy命令,改命令会将用户的jars部署到Release或者Snapshot仓库,这取决用户创建的是release还是snapshot工程。
在这里插入图片描述

更多精彩内容关注

微信公众账号

猜你喜欢

转载自blog.csdn.net/weixin_38231448/article/details/92075983