Docker版安装部署 Nexus 及阿里云仓库与本地仓库配置

一、Nexus安装部署

  1、docker search nexus

  2、docker pull docker.io/sonatype/nexus3

  3、mkdir -p /opt/nexus/data                      //创建挂载数据目录

  4、chmod 777 /opt/nexus/data                 //设置文件访问权限或启动容器命令中添加 --privileged=true 

  5、docker run -itd -p 18081:8081 --name nexus -e NEXUS_CONTEXT=nexus -v /opt/nexus/data:/nexus-data  --restart=always docker.io/sonatype/nexus3               //NEXUS_CONTEXT=nexus表示web访问时需添加/nexus路径

二、仓库配置

  1、登陆 http://192.168.1.180:18081/nexus/

  用户名:admin 密码在data目录下生成的 admin.password 文件,登陆并修改密码

  2、配置阿里云及中央仓库

 

  

 

 

 

 

 

 

 

 

 

 

 

 

 

  3、选择 maven2(proxy)

  4、依次设置添加代理仓库路径--阿里云仓库代理服务 https://maven.aliyun.com/mvn/guide

  

  

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  5、自助选择添加其它仓库

1. aliyun
    http://maven.aliyun.com/nexus/content/groups/public
2. apache_snapshot
    https://repository.apache.org/content/repositories/snapshots/
3. apache_release
    https://repository.apache.org/content/repositories/releases/
4. atlassian
    https://maven.atlassian.com/content/repositories/atlassian-public/
5. datanucleus
    http://www.datanucleus.org/downloads/maven2
6. maven-central (安装后自带,仅需设置Cache有效期即可)
    https://repo1.maven.org/maven2/
7. nexus.axiomalaska.com
    http://nexus.axiomalaska.com/nexus/content/repositories/public
8. oss.sonatype.org
    https://oss.sonatype.org/content/repositories/snapshots
9.pentaho
    https://public.nexus.pentaho.org/content/groups/omni

  

  6、将所有代理仓库加入组

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

三、Maven配置

  1、打开maven配置文件 D:\program\dev\apache-maven-3.8.1\conf\settings.xml

  2、修改setting.xml中<servers>和<mirrors>标签

  <servers>
    <server>
      <id>releases</id>
      <username>admin</username>
      <password>123456</password>
    </server>
    
    <server>
      <id>snapshots</id>
      <username>admin</username>
      <password>123456</password>
    </server>
  </servers>
  <mirrors>
      <mirror>
      <id>yundun</id>
      <mirrorOf>*</mirrorOf>
      <name>yundun maven</name>
      <url>http://192.168.1.180:18081/nexus/repository/maven-public/</url>
    </mirror>
  </mirrors>

四、pom配置

  在项目pom.xml文件中添加,其中id要与etting.xml中<server>的id一致

    <distributionManagement>
        <repository>
            <id>releases</id>
            <name>Releases</name>
            <url>http://192.168.1.180:18081/nexus/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>snapshots</id>
            <name>Snapshots</name>
            <url>http://192.168.1.180:18081/nexus/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

五、测试

  编译项目:mvn deploy

  maven会根据项目版本后缀 <version>0.0.1-SNAPSHOT</version>,分别编译至仓库中

  

 

posted @ 2021-07-30 17:14  远离颠倒梦想  阅读(1031)  评论(0编辑  收藏  举报