7

nexus3搭建分享

 3 years ago
source link: https://blog.shareworld.vip/archives/nexus3-build
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

nexus3搭建分享

Owen Jia 2020年08月15日 71次浏览

Nexus是公共Jar管理私服平台,一般我们都简称“私服”。

Java研发体系中,团队内部的公共jar和第三方公共jar都会存放在各自私服中,通过也有在网络中公开的私服,比较Maven的中央仓库就是全球公开,又比如阿里公开其对外私服。

Nexus目前已经发展到第三代,称为nexus3。我们这里就是只有sonatype团队贡献的官方私服nexus3进行搭建,其实也有很多其他私服服务可供使用。

采用docker方式部署,这是最简单方便的办法。

下载nexus3镜像

推荐使用官方image,"sonatype/nexus3",或者用search查找其他image都可,看你喜欢了。

执行docker pull sonatype/nexus3

配置docker-compose.yml

image.png

image.png

提示:端口绑定第二个8081不能改,数据存放位置必须绑定。

image.png

image.png

初始默认密码在admin.password文件内,是初始启动生成的随机码,文件路径在/usr/local/docker/nexus/data目录中。

成功后就提升修改密码!!!

因为我们的公司服务器网络是隔离的,需要配置nexus3的代理。

image.png

image.png

搭建System下HTTP模块,按照提升配置即可。

配置新用户

在nexus3的Security模块中,添加新的角色(deploy-user)和用户(deploy001),这里最重要的是角色要添加nx-repository-admin--add、nx-repository-admin--edit、nx-repository-admin--read和nx-repository-view-maven2--add、nx-repository-view-maven2--edit、nx-repository-view-maven2--read权限,这样deploy-user用户才能具备jar的下载和上传能力。

Nexus3默认是几个核心仓库已经有了,releases\snapshots\public\central,release和snapshots是我们用了上传的jar,public是一个group类型仓库,用了统一下载三方jar的。central是maven的中央仓库,若果觉得满可以换成阿里的,也可以重新创建一个repository用了代理阿里仓库。

工程中引入

找到maven的.m2/setting.xml文件,一般默认用户目录下。

在里面添加server\mirror\profie,具体不介绍。

settings.xml

image.png

image.png

pom.xml

image.png

image.png

同同时还要在项目工程的pom.xml中添加distributionManagement配置,这里要注意repository的id要和server里用户id节点名字相同。

结束,docker方式配置首推荐。

后续研究nexus3浏览docker image,听说可以支持。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK