DockerCompse搭建Nexus以及使用

一、概述

Nexus 是一个强大的仓库管理器,极大地简化了内部仓库的维护和外部仓库的访问。
定位

二、基于Docker安装

compose配置文件

version: '3.1'
services:
  nexus:
    restart: always
    image: sonatype/nexus3
    container_name: nexus
    ports:
      - 8081:8081
    volumes:
      - /usr/local/docker/nexus/data:/nexus-data

注: 启动时如果出现权限问题可以使用:chmod 777 /usr/local/docker/nexus/data 赋予数据卷目录可读可写的权限

三、控制台验证安装

地址:http://ip:port/ 用户名:admin 密码:admin123
验证

四、nexus仓库种类介绍

maven-central : 和官方相关联
maven-public :其它三个仓库的合集,一般使用这个就行
maven-releases: 发行版本,不可变
maven-snapshots: 快照版本,可变

五、配置使用

1.setting.xml 配置账号密码

<server>
  <id>nexus-releases</id>
  <username>admin</username>
  <password>admin123</password>
</server>

<server>
  <id>nexus-snapshots</id>
  <username>admin</username>
  <password>admin123</password>
</server>

2.pom配置私服代理仓库和上传仓库路径

  • 上传配置:

    <distributionManagement>  
    <repository>  
      <id>nexus-releases</id>  
      <name>Nexus Release Repository</name>  
      <url>http://127.0.0.1:8081/repository/maven-releases/</url>  
    </repository>  
    <snapshotRepository>  
      <id>nexus-snapshots</id>  
      <name>Nexus Snapshot Repository</name>  
      <url>http://127.0.0.1:8081/repository/maven-snapshots/</url>  
    </snapshotRepository>  
    </distributionManagement> 

    注意事项:

  • ID 名称必须要与 settings.xml 中 Servers 配置的 ID 名称保持一致。

  • 项目版本号中有 SNAPSHOT 标识的,会发布到 Nexus Snapshots Repository, 否则发布到 Nexus Release Repository,并根据 ID 去匹配授权账号。

  • 私服配置:

    <repositories>
      <repository>
          <id>nexus</id>
          <name>Nexus Repository</name>
          <url>http://127.0.0.1:8081/repository/maven-public/</url>
          <snapshots>
              <enabled>true</enabled>
          </snapshots>
          <releases>
              <enabled>true</enabled>
          </releases>
      </repository>
    </repositories>
    <pluginRepositories>
      <pluginRepository>
          <id>nexus</id>
          <name>Nexus Plugin Repository</name>
          <url>http://127.0.0.1:8081/repository/maven-public/</url>
          <snapshots>
              <enabled>true</enabled>
          </snapshots>
          <releases>
              <enabled>true</enabled>
          </releases>
      </pluginRepository>
    </pluginRepositories>

3.部署到私服

mvn deploy

4.上传第三方jar到私服

上传界面


转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 18846433665@163.com

文章标题:DockerCompse搭建Nexus以及使用

文章字数:573

本文作者:Xu Shengcai

发布时间:2019-10-28, 21:17:51

最后更新:2019-10-28, 23:15:11

原始链接:http://yoursite.com/2019/10/28/DockerCompse搭建Nexus以及使用/

版权声明: "署名-非商用-相同方式共享 4.0" 转载请保留原文链接及作者。

目录
×

喜欢就点赞,疼爱就打赏