私服搭建

**搭建私服**

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文件中,配置私服用户名、密码

releases
admin
admin123


snapshots
admin
admin123


2. 在所要上传的项目中pom.xml中指定往哪传


releases
http://localhost:8081/nexus/content/repositories/releases/


snapshots
http://localhost:8081/nexus/content/repositories/snapshots/



3. 输入命令:deploy上传

----------

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

1. 在settings.xml配置文件中配置模板,告诉maven从哪下载jar包,配置组仓库


dev



nexus

http://localhost:8081/nexus/content/groups/public/


true



true







public
Public Repositories
http://localhost:8081/nexus/content/groups/public/




2. 在settings.xml配置文件中激活模板

dev


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

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

你可能感兴趣的:(私服搭建)