利用Nexus搭建Maven服务器

阐述如果利用Nexus来快速搭建maven仓库的私有服务器 私服搭建 Docker Hub链接地址: https://hub.docker.com/r/sonatype/nexus/

docker pull sonatype/nexus mkdir /data/nexus-data && chown -R 200 /data/nexus-data docker run -d -p 8081:8081 --name nexus -v /data/nexus-data:/nexus-data sonatype/nexus3​

本地Maven配置 ​修改Maven的全局setting.xml文件如下:

文件路径: $MAVEN_HOME/conf/setting.xml

mirrors节点加入如下内容 nexus * Nexus http://192.168.1.80:8081/repository/maven-public/

profiles节点加入如下内容 nexus central http://central true true central http://central true true

activeProfiles​节点加入

nexus

对于Snapshot的jar,如果想及时的更新,可以在maven参数中加上-U,就可以获得最新的jar包。 本地组件deploy 除了配置本地Maven配置外,还需要在setting.xml文件中加入如下内容:

servers节点 maven-releases admin admin123 maven-snapshots admin admin123

项目的pom.xml文件,加入如下配置: maven-releases http://192.168.1.​80:8081/repository/maven-releases/ maven-snapshots http://192.168.1.80:8081/repository/maven-snapshots/

最后更新于 3rd Nov 2022