03 docker 搭建 Nexus maven 私服

1、下载镜像 docker pull sonatype/nexus3:3.38.0
2、创建yml 文件 docker-nexus.yml
3、编写内容

version: '2'

services:
  nexus:
    image: sonatype/nexus3:3.38.0  #ima 版本
    container_name: nexus #容器名称
    restart: always #进程挂了 重启方式
    ports:
      - "8081:8081"
    volumes:
      - nexus-data:/nexus-data
volumes:
    # 外部数据卷 nexus-data 这里不指定值的话,
    # 格式  name:宿主机位置 可以为空 默认就在 var/lib/docker/volumes/<目录名称>
  nexus-data: 

4、启动 docker-compose -f docker-nexus.yml up -d
访问 http://192.168.100.53:8081/
这个密码 默认在 : /nexus-data/admin.password 账号就是 admin
5、登录进入改密码,等等操作
简单接介绍一下
maven-central 中央仓库,
maven-releases 发行版,即正式版本,不允许修改
maven-snapshots 快照,相当于开发版本,不用改版本号
maven-public 这个包含上面三个版本的仓库 分组的概念 一般是用这个public

外部版本号  V1.0.0
     根据语义化规范意思 第一位版本号、第二位修改功能增加、第三位 改BUG次数
内部版本号:  00001 0002 计算机识别,比如0002大于00001 就提示有更新

6、拉取jar 包
使用方式 在spring boot 项目 pom.xml 里面添加

 <!-- 私有仓库地址 -->
    <repositories>
        <repository>
            <id>nexus</id>
            <name>nexus Repositories</name>
            <url>http://192.168.100.53:8081/repository/maven-public/</url>
            <!-- 是否使用发行版 -->
            <releases>
                <enabled>true</enabled>
            </releases>
            <!-- 是否使用快照 -->
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <!-- 这个指的build 里面的插件 ,插件是需要从仓库拉取的,如果不配置,插件就会走maven.xml 里面的地址拉取, -->
    <pluginRepositories>
        <pluginRepository>
            <id>nexus</id>
            <name>nexus Repositories</name>
            <url>http://192.168.100.53:8081/repository/maven-public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <SNAPSHOT>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>

7、推送 deploy jar
maven.xml 里面添加

 	<server>
          <id>nexus_snapshots</id>
          <username>nexus_ttbgz</username>
          <password>ttbgz</password>
      </server>
      <server>
          <id>nexus_releases</id>
          <username>nexus_ttbgz</username>
          <password>ttbgz</password>
       </server> 

pom.xml 里还需要添加

 <!--分发 上传 私服库 -->
    <distributionManagement>
        <!-- 发行版 -->
        <repository>
            <id>nexus_releases</id>
            <name>Nexus releases</name>
            <url>http://192.168.100.53:8081/repository/maven-public/</url>
        </repository>
        <!-- 快照 -->
        <snapshotRepository>
            <id>nexus_snapshots</id>
            <name>Nexus snpahots</name>
            <url>http://192.168.100.53:8081/repository/maven-public/</url>
        </snapshotRepository>
    </distributionManagement>

特别说明:这里也是配置了两个 快照和发行,具体走哪个,是根据你项目 标签
在这里插入图片描述-SNAPSHOT 这个版本后缀来的,如果没有-SNAPSHOT 就是发行版本

备注:
如果想专门创建一个 deploy 的角色的权限 给
nx-component-upload
nx-repository-view-maven2--
#一个是上传权限,第二个是view 页面权限,- 懂得都懂

nx-repository-view-maven2--add #:上传jar包权限
nx-repository-view-maven2-
-browse#浏览权限
nx-repository-view-maven2--delete#删除
nx-repository-view-maven2-
-edit#编辑
nx-repository-view-maven2-*-read#读取jar包详细信息
nx-userschangepw #这个是开放用户修改密码的

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值