私服搭建

**搭建私服**

1. 安装nexus,nexus是maven的仓库管理器,使用它搭建私服。
* 第一步:解压nexus-2.12.0-01-bundle.zip文件
* 第二步:开启nexus的服务,进入到nexus-2.12.0-01\bin目录下(强调:要使用管理员的权限打开dos窗口)
* cd D:\class\resource\nexus\nexus-2.12.0-01\bin
* d: 回车进入
* 输入命令:nexus install
* 强调:如果想卸载nexus,输入命令:nexus uninstall

* 启动服务,输入命令:nexus start

* 第三步:找到conf目录下的nexus.properties配置文件,里面包含nexus的访问地址
application-port=8081
application-host=0.0.0.0
nexus-webapp=${bundleBasedir}/nexus
nexus-webapp-context-path=/nexus

* 访问地址:http://localhost:8081/nexus

* 第四步:使用默认账号登录
* 用户名:admin
* 密码:admin123

2. 查看nexus的仓库类型
* Hosted:宿主仓库
* 放入本公司开发的测试版本jar包,正式版本的jar包。

* Proxy:代理仓库
* 用于代理远程的公共仓库,例如maven的中央仓库。当用户连接私服,如果私服中没有jar包,会默认从中央仓库下载jar包。

* Group:组仓库
* 将其他仓库组合到一起,将来直接连接组仓库。

* Virtual:虚拟仓库(不用)
* Maven1的jar包

----------

**把本地jar包上传到私服(不用记配置文件)**

1. Maven解压安装包中conf\setttings.xml文件中,配置私服用户名、密码
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>

2. 在所要上传的项目中pom.xml中指定往哪传
<distributionManagement>
<repository>
<id>releases</id>
<url>http://localhost:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>

3. 输入命令:deploy上传

----------

**从私服上下载jar包**

1. 在settings.xml配置文件中配置模板,告诉maven从哪下载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. 在settings.xml配置文件中激活模板
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>

3. 进行测试
* 把ssh_dao子工程关闭掉,但是service会引用dao的jar包。
* 再把本地仓库的daojar包也删除掉
* 更新service的项目,会发现从组仓库中下载jar包到本地仓库。

转载于:https://www.cnblogs.com/lrxi/p/6965241.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值