Nexus 安装配置教程

Nexus 安装配置教程

目录为什么使用 NexusDocker 模式安装 Nexus使用 data volume使用本地目录Nexus 配置配置 Blob StoresNexus 使用包下载包上传参考

为什么使用 Nexus

Nexus 最为大家熟知的功能就是 maven 的依赖包管理器。其实 Nexus 的功能不仅仅是 maven 的包管理,它还可以做 .net 包管理,docker 镜像管理,甚至还可以做 yum 源。这篇文章主要介绍 Nexus 的 maven 依赖管理功能,介绍 Nexus 的安装,配置。

架设 Nexus 私服有以下优点:

节省公司外网贷款;

因为依赖会被缓存到私服上,所以依赖的下载速度会很快;

方便上传团队内部的依赖,统一管理,共享。

Docker 模式安装 Nexus

我们选择使用 Docker 的方式安装 Nexus。

Nexus的官方网站:https://www.sonatype.com/products/repository-oss-download

Nexus的官方帮助文档:https://help.sonatype.com/repomanager3

Nexus的Docker安装介绍:https://help.sonatype.com/repomanager3/installation/installation-methods#InstallationMethods-InstallingwithDocker

官方有两种方式

使用 docker 的 data volume (推荐)

使用本地目录作为 container 的 volume

使用 data volume

docker volume create --name nexus-data

docker run -d -p 8081:8081 --name nexus -v nexus-data:/nexus-data sonatype/nexus3

使用本地目录

mkdir nexus

cd nexus

docker run -d -p 8081:8081 --name nexus -v $PWD/nexus-data:/nexus-data sonatype/nexus3

安装起来特别简单。

安装完毕,访问 127.0.0.1:8081,可以直接登陆。

Nexus 配置

关于怎么配置 Nexus 这边不做太详细的说明。对默认的几个仓库坐下说明。

默认情况下,Nexus 会帮我们创建几个仓库:

maven-central:代理仓库,一般会连接外部的中央仓库;

maven-public:仓库组,一般提供这个仓库给公司内部的同事使用;

maven-release:本地仓库,一般用于存放公司内部开发的Jar包;

maven-snapshots:本地仓库,存放公司开发的snapshot版本的包;

maven-3rd-party:本地仓库,存放第三方的Jar包。

配置 Blob Stores

Nexus 使用

包下载

如果你只需要使用包下载功能,只需要替换本地的settings.xml即可。

D:\software\maven\Repository

nexus

devops

password

nexus

nexus

http://xx.xx.xx.xx:18081/repository/maven2-public/

nexus

nexus

http://nexus

true

true

nexus

http://nexus

true

true

nexus

包上传

方法一:通过 Nexus 界面上传

给用户开通上传Jar包的权限。用户就可以通过页面上传Jar包了。

方法二:通过配置pom文件进行Jar包上传

在项目的pom中加入以下的配置。

nexus

nexus-snapshot

http://xx.xx.xx.xx:18081/repository/maven2-snapshots/

nexus

nexus-release

http://xx.xx.xx.xx:18081/repository/maven2-releases/

完成此步骤后,我们就可以通过执行mvn clean deploy进行发布了。Deploy插件会根据Maven项目中定义的version值决定是使用nexus-snapshot仓库还是nexus-release仓库。当version值是以-SNAPSHOT后缀结尾时,则发布到nexus-snapshot仓库。

方法三:通过命令行(实质和上面pom的形式一样)

mvn deploy:deploy-file -DgroupId=com.jd.jr.xx -DartifactId=gateway-xx -Dversion=1.8.xx-SNAPSHOT -Dpackaging=jar -Dfile=xx-api-1.8.0-RELEASE.jar -Durl=http://124.205.xx.xx:18081/repository/maven2-snapshots/ -DrepositoryId=nexus

上面的-DrepositoryId=nexus需要和配置的server标签匹配起来。

参考

nexus3 通过pom.xml配置上传jar包

https://davidwangtm.github.io/2016/10/07/docker_nexus_introduction/

相关文章

如何删除Steam推荐标签:高效管理你的游戏体验
28365备用网址官方网站

如何删除Steam推荐标签:高效管理你的游戏体验

🕒 09-21 👁️ 9754
详细步骤教你如何轻松注册Facebook新账号
谁知道365足球网站

详细步骤教你如何轻松注册Facebook新账号

🕒 10-02 👁️ 248
山药炒木耳
28365备用网址官方网站

山药炒木耳

🕒 12-11 👁️ 8086