Maven私服一般安装Nexus。
首先,Nexus下载,访问Nexus官方网址https://www.sonatype.com/download-nexus-repo-oss
![](https://img2020.cnblogs.com/blog/2210127/202011/2210127-20201117215635474-145305426.png)

下载完成后是个压缩包
![](https://img2020.cnblogs.com/blog/2210127/202011/2210127-20201117215627925-1817164585.png)

第二步 配置:
1)将上一步下载的nexus解压
![](https://img2020.cnblogs.com/blog/2210127/202011/2210127-20201117215624176-1444718546.png)

2)端口和监听配置
![](https://img2020.cnblogs.com/blog/2210127/202011/2210127-20201117215620742-1161528536.png)

![](https://img2020.cnblogs.com/blog/2210127/202011/2210127-20201117215616983-1352723934.png)

application-port:监听端口
application-host:监听主机
nexus-context-path:上下文路径
4) 运行环境配置
![](https://img2020.cnblogs.com/blog/2210127/202011/2210127-20201117215610802-200505395.png)

![](https://img2020.cnblogs.com/blog/2210127/202011/2210127-20201117215602604-873603920.png)

第三步安装:
方式一:以管理员身份运行cmd窗口 进入路径【D:\Program Files\nexus-3.28.1-01\bin】执行.\nexus.exe /run
![](https://img2020.cnblogs.com/blog/2210127/202011/2210127-20201117215556640-367618726.png)

方式二:使用本地服务的方式启动,
1) 安装服务:以管理方式打开cmd,进入路径【D:\Program Files\nexus-3.28.1-01\bin】,执行命令./nexus.exe /install
![](https://img2020.cnblogs.com/blog/2210127/202011/2210127-20201117215551366-41957054.png)

2) 启动服务:执行命令:net start nexus

![](https://img2020.cnblogs.com/blog/2210127/202011/2210127-20201117215546433-1078042488.png)

注:
关闭服务:net stop nexus
卸载服务:./nexus.exe /uninstall
![](https://img2020.cnblogs.com/blog/2210127/202011/2210127-20201117215541986-543574415.png)

第四步启动、访问
访问路径: http://127.0.0.1:8081/
用户名:admin
打开文件:D:\Program Files\sonatype-work\nexus3\admin.password
![](https://img2020.cnblogs.com/blog/2210127/202011/2210127-20201117215533486-228888628.png)

复制密码到密码输入框中
![](https://img2020.cnblogs.com/blog/2210127/202011/2210127-20201117215526547-332275052.png)

登陆成功后展示
![](https://img2020.cnblogs.com/blog/2210127/202011/2210127-20201117215518014-828015190.png)

![](https://img2020.cnblogs.com/blog/2210127/202011/2210127-20201117215514239-473687726.png)

说明:
hosted:宿主仓库,主要存储本公司或团队开发的jar包
proxy:代理仓库,代理中央仓库和apache下测试版本的jar包
group:组仓库,将来连接组仓库。包含Hosted:宿主库,proxy:代理仓库
virtual:虚拟仓库,仓库废弃后会存存储到虚拟仓库

第五步 maven配置私服下载配置
打开文件【D:\Program Files\apache-maven-3.6.3\conf\settings】,
![](https://img2020.cnblogs.com/blog/2210127/202011/2210127-20201117215507829-775119678.png)

找到节点【profiles】在该节点在新建profile
mfc-dev



maven-central

maven-central

http://127.0.0.1:8081/repository/maven-central/


true



true




my

my

http://127.0.0.1:8081/repository/maven-releases//


true



true



public
Public Repositories
http://127.0.0.1:8081/repository/maven-central/
![](https://img2020.cnblogs.com/blog/2210127/202011/2210127-20201117215456402-1755201149.png)

在节点activeProfiles下加入

mfc-dev

来激活profile
![](https://img2020.cnblogs.com/blog/2210127/202011/2210127-20201117215450871-1967115494.png)

测试
先去本地仓库把项目A依赖的项目B的jar删除,项目A报错,然后会从私服上下载,完成后检查是否下载成功。
第六步maven上传jar到私服
打开文件【D:\Program Files\apache-maven-3.6.3\conf\settings】,
![](https://img2020.cnblogs.com/blog/2210127/202011/2210127-20201117215444527-86473465.png)

在【servers】下新增节点【server】如下

releases
admin admin1234

注意:settings.xml中server元素下id的值必须与POM中repository或snapshotRepository下id的值完全一致。将认证信息放到settings下而非POM中,是因为POM往往是它人可见的,而settings.xml是本地的。
![](https://img2020.cnblogs.com/blog/2210127/202011/2210127-20201117215430665-577170883.png)

在要上传的项目的pom文件中配置


nexus-releases
Nexus Release Repository
http://127.0.0.1:8081/repository/maven-releases/


nexus-snapshots
Nexus Snapshot Repository
http://127.0.0.1:8081/repository/maven-snapshots/


![](https://img2020.cnblogs.com/blog/2210127/202011/2210127-20201117215424810-1296228319.png)

点击【deploy】把应用打包并上传到私服
![](https://img2020.cnblogs.com/blog/2210127/202011/2210127-20201117215419558-751751783.png)

上传到私服完成查看私服:

![](https://img2020.cnblogs.com/blog/2210127/202011/2210127-20201117215408493-278706453.png)