1.在Docker Hub上找到 sonatype/nexus 镜像
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 进行修改
点击Log In 输入账号密码 默认账号密码为
admin admin123
5.配置nexus参数并上传项目
在引用Maven版本修改settings.xml
<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发布地址
<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一致 别问为什么 我不知道!!!
开始测试上传
上传成功,在Nexus查看
上传成功
6.下载依赖
点击Repositories
点击Public Repositories
点击 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文件中
框2复制粘贴 成功导入!
over!