在 部署 Nexus 私服 这篇文章中配置了 Nexus 的服务端,接下来要配置一下本地 maven 如何连接 Nexus 服务端使用。
Maven 私服配置
1、首先打开我们本地 maven 的配置文件
2、一般情况下我们会修改本地仓库位置
3、配置镜像仓库
- 修改
元素 - id:需要与
中的 id 匹配 - mirrorOf:可以填入 central(只有通过中央仓库下载的依赖才会从私服下载) 或 * (所有依赖均通过私服下载)
- name:随便
- url:仓库地址
- id:需要与
nexus-public * Nexus Public http://192.168.228.18:8081/repository/maven-public/
如果 Nexus 服务端没有 开启匿名访问 的话,需要在
nexus-public admin 123456
4、通过 mvn deploy 命令推送 jar 包到私服
- 配置
访问认证信息
nexus-releases admin 123456 nexus-snapshots admin 123456
- 配置项目中的 pom.xml 文件,这里的 id 要与上面 server 中的 id 对应
完整的 pom.xmlnexus-releases Nexus Release Repository http://192.168.228.18:8081/repository/maven-releases/ nexus-snapshots Nexus Snapshot Repository http://192.168.228.18:8081/repository/maven-snapshots/
npm 私服配置D:repo nexus-public admin 123456 nexus-releases admin 123456 nexus-snapshots admin 123456 nexus-public * Nexus Public http://192.168.228.18:8081/repository/maven-public/
在 部署 Nexus 服务端 ,配置仓库的时候,我们知道 Nexus 不仅可以作为 maven 的私服,还可以作为 docker、apt、npm 等依赖管理工具的私服,这里我们配置一下 npm 私服仓库
1、配置代理仓库,代理淘宝镜像源
- npm(proxy)
- Name:npm-taobao
- Remote storage:https://registry.npm.taobao.org
2、配置私有仓库
- npm(hosted)
- Name:npm-hosted
3、配置分组仓库
- npm(group)
- Name:npm-public
- Group:包含 npm-taobao 和 npm-hosted



