docker搭建Nexus3实现自己的maven私服

本文档详细介绍了如何通过Docker拉取Nexus3镜像,启动容器,并配置Maven settings.xml,以便将项目发布到Nexus3私服。默认用户名为admin,密码为admin123。同时,提供了在pom.xml中添加distributionManagement的步骤,确保项目能正确发布。
摘要由CSDN通过智能技术生成
1.拉取镜像
docker pull sonatype/nexus3
2.启动容器
sudo docker run -itd --name nexus3 --restart=always -p 8088:8088 -p 8081:8081 -p 5000:5000 -v /mnt/gv0/nexus-data:/nexus-data sonatype/nexus3
3.修改maven settings.xml 这里使用默认用户名 admin 密码 admin123
<?xml version="1.0" encoding="UTF-8"?>

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <!-- pluginGroups
   | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
   | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
   | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
   |-->
  <pluginGroups>

  </pluginGroups>
  <!-- proxies
   | This is a list of proxies which can be used on this machine to connect to the network.
   | Unless otherwise specified (by system property or command-line switch), the first proxy
   | specification in this list marked as active will be used.
   |-->
  <proxies>

  </proxies>

  <!-- servers
   | 这里填写nexus上面的登录账号密码
   |-->
  <servers>
      <server>
        <id>sonatype-nexus-snapshots</id>
        <username>admin</username>
        <password>admin123</password>
      </server>
  </servers>

  <!-- servers
   | 选用阿里云的镜像
   |-->
  <mirrors>
     <mirror>
      <id>nexus-aliyun</id>
      <mirrorOf>central</mirrorOf>
      <name>Nexus aliyun</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public</url>
     </mirror>
  </mirrors>

  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <!-- 这是设置仓库 -->
      <repositories>
        <repository>
          <id>sonatype-nexus-snapshots</id>
          <url>http://服务器:8081/repository/maven-snapshots</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <updatePolicy>always</updatePolicy>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>
    </profile>
  </profiles>
</settings>
4.如果项目需要发布到nexus,修改pom 添加以下 distributionManagement 内容
<distributionManagement>
        <repository>
            <id>sonatype-nexus-snapshots</id>
            <name>Releases</name>
            <url>http://服务器:8081/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>sonatype-nexus-snapshots</id>
            <name>Snapshot</name>
            <url>http://服务器:8081/repository/maven-snapshots/</url>
        </snapshotRepository>
</distributionManagement>
5.注意点
1、首先idea的maven路径不要使用自生maven 使用我们下载的
2、setting.xml文件的server的id要和distributionManagement的repository的id保持一致
3、如果是多模块工程distributionManagement要写在父pom里面
4、maven的setting.xml文件要摄像拉取jar包的仓库
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值