nexus-私服

一、下载

链接:Linux
提取码:oceg
链接:Windows
提取码:eq5a

二、安装

以Windows为例
1、将文件解压到没有中文没有空格的目录中,解压完后有两个文件夹
在这里插入图片描述
2、以管理员身份打开命令提示符(黑窗口)
3、进入解压的目录下nexus-2.12.0-01的bin中,输入nexus.bat install
在这里插入图片描述

三、启动

1、在同样的路径下,输入nexus.bat start
在这里插入图片描述
2、nexus-2.12.0-01-bundle\nexus-2.12.0-01\conf\nexus.properties
在这里插入图片描述
3、浏览器中输入http://localhost:8081/nexus
在这里插入图片描述
仓库的类型
1)hosted,宿主仓库, 部署自己的 jar 到这个类型的仓库,包括 releases 和 snapshot 两部
分, Releases 公司内部发布版本仓库、 Snapshots 公司内部测试版本仓库
2)proxy,代理仓库, 用于代理远程的公共仓库,如 maven 中央仓库,用户连接私服,私
服自动去中央仓库下载 jar 包或者插件。
3)group,仓库组,用来合并多个 hosted/proxy 仓库,通常我们配置自己的 maven 连接仓
库组。
4)virtual(虚拟):兼容 Maven1 版本的 jar 或者插件

四、应用

将自己的代码传到私服上
1、修改Maven的settings.xml,在<server></server>中加入

	<server>
		<id>releases</id>
		<username>admin</username>
		<password>admin123</password>
	</server>
	<server>
		<id>snapshots</id>
		<username>admin</username>
		<password>admin123</password>
	</server>

在这里插入图片描述
2、上传哪个模块的代码,就把对应模块的pom文件中加入以下内容

<distributionManagement>
	<repository>
		<id>releases</id>
		<url>http://localhost:8081/nexus/content/repositories/releases/</url> <!--注意修改IP地址-->
	</repository>
	<snapshotRepository>
		<id>snapshots</id>
		<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
	</snapshotRepository>
</distributionManagement>

3、如果想把jar包上传到远程仓库,那就会执行Maven的默认生命周期最后一个阶段deploy,上传哪个模块就启动那哪个模块的deploy
在这里插入图片描述
注意:以上操作只能保证能上传jar包,不能保证可以下载jar包,配置以下文件,将保证既能上传又能下载jar包
1、修改Maven的settings.xml,在<profile></profile>中加入

	<!-- 下载jar包配置 -->
	<profile> 
		<!--profile的id -->
		<id>dev</id>
		<repositories>
			<repository> <!--仓库id,repositories可以配置多个仓库,保证id不重复 -->
				<id>nexus</id> <!--仓库地址,即nexus仓库组的地址 -->
				<url>http://localhost:8081/nexus/content/groups/public/</url> <!--是否下载releases构件 -->
				<releases>
					<enabled>true</enabled>
				</releases> <!--是否下载snapshots构件 -->
				<snapshots>
					<enabled>true</enabled>
				</snapshots>
			</repository>
		</repositories>
		<pluginRepositories> <!-- 插件仓库,maven的运行依赖插件,也需要从私服下载插件 -->
			<pluginRepository> <!-- 插件仓库的id不允许重复,如果重复后边配置会覆盖前边 -->
				<id>public</id>
				<name>Public Repositories</name>
				<url>http://localhost:8081/nexus/content/groups/public/</url>
			</pluginRepository>
		</pluginRepositories>
	</profile>

2、激活,在</profile>后</settings>加入

	<activeProfiles>
		<activeProfile>dev</activeProfile>
	</activeProfiles>

五、卸载

进入解压的目录下nexus-2.12.0-01的bin中,输入nexus.bat uninstall

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值