Docker安装Nexus2私有仓库与POM配置

1.在Docker Hub上找到 sonatype/nexus 镜像

image.png

2.Docker拉取指定镜像

docker pull sonatype/nexus:oss

3.启动容器

docker run -tid -p 8081:8081 --name nexus -e NEXUS_CONTEXT=nexus -v /data/docker/nexus:/nexus-data  sonatype/nexus:oss

4. 等待5-10s查看管理页面

浏览器访问 http://IP:Prot/nexus/index.html
其中 IP 为宿主机器 IP,读者可根据自己的 ip 进行修改image.png
点击Log In 输入账号密码 默认账号密码为
admin admin123image.png

5.配置nexus参数并上传项目

image.png
在引用Maven版本修改settings.xmlimage.png

<servers>
	<server>
	  <id>releases</id>
	  <username>你的Nexus账号</username>
	  <password>你的Nexus密码</password>
	</server>
	<server>
	  <id>snapshots</id>
	  <username>你的Nexus账号</username>
	  <password>你的Nexus密码</password>
	</server>
  </servers>

在你要发布的项目里配置Nexus发布地址image.png

<distributionManagement>
        <repository>
            <id>releases</id>
            <name>Nexus Release Repository</name>
            <url>http://IP:Prot/nexus/content/repositories/releases/</url>
        </repository>
        <snapshotRepository>
            <id>snapshots</id>
            <name>Nexus Snapshot Repository</name>
            <url>http://IP:Prot/nexus/content/repositories/snapshots/</url>
        </snapshotRepository>

切记Id必须要与settings.xmlId一致 别问为什么 我不知道!!!

开始测试上传image.pngimage.png
上传成功,在Nexus查看image.png
上传成功

6.下载依赖

点击Repositoriesimage.png
点击Public Repositoriesimage.png
点击 Public Repositories ,再点击 Configuration,可以看见上边的仓库都已经引入到了 Public Repositories 中
所以我们在使用时只需要引入 Public Repositories 的 Repository Path 即可
将上边标记的 Public Repositories 的 Repository Path 复制下来
在项目的 pom 文件中填上如下内容

<repositories>
    <repository>
        <id>nexus</id>
        <name>Nexus Repository</name>
        <url>http://IP:Prot/nexus/content/groups/public/</url>
    </repository>
</repositories>

粘贴在Pom.xml文件中image.png
框2复制粘贴 成功导入!

over!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

R6N

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值