Nexus 私服搭建

Nexus 私服搭建

部署

使用Docker Compose部署

version: '3'
services:
  nexus:
    container_name: nexus
    image: sonatype/nexus3
    restart: always
    ports:
      - "900:8081"
    # 数据卷的映射
    volumes:
      - ./data:/nexus-data

docker -logs nexus -f 查看日志,打印如下信息则启动成功。默认账号密码为 admin admin123

访问地址为:host:900

在这里插入图片描述

访问Web界面

在这里插入图片描述

配置Nexus - Maven

  1. 登录用户,进入管理界面,选择Repositories
    在这里插入图片描述

  2. 创建阿里云代理仓库(其他maven仓库同理)https://maven.aliyun.com/repository/public

    1. 选择仓库类型为代理仓库
      在这里插入图片描述
    2. 填写仓库信息,填完后下拉创建仓库
      在这里插入图片描述
  3. 应用代理仓库

    1. 进入仓库管理页面,选择maven-public
      在这里插入图片描述

    2. 选择刚刚创建的代理仓库添加到引用列表,并上移顺序到第一,保存应用。
      在这里插入图片描述在这里插入图片描述

  4. 修改本地Maven setting配置文件

    <?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">
        <!-- 本地仓库 -->
        <localRepository>D:\Environment\LocalRepository\.m2</localRepository>
        <mirrors>
            <!-- 本地私服 -->
            <mirror>
                <id>local-nexus</id>
                <name>mirror</name>
                <mirrorOf>*</mirrorOf>
                <url>http://1.12.3.137:900/repository/maven-public/</url>
            </mirror>
        </mirrors>
        <servers>
            <!-- 本地 Nexus 私服 -->
            <server>
                <id>local-nexus</id>
                <username>admin</username>
                <password>zxc123..</password>
            </server>
            <server>
                <id>local-nexus-releases</id>
                <username>admin</username>
                <password>zxc123..</password>
            </server>
            <server>
                <id>local-nexus-snapshots</id>
                <username>admin</username>
                <password>zxc123..</password>
            </server>
        </servers>
        <profiles>
            <>
                <id>local-nexus</id>
                <properties>
                    <altReleaseDeploymentRepository>
                        local-nexus-releases::default::http://1.12.3.137:900/repository/maven-releases/
                    </altReleaseDeploymentRepository>
                    <altSnapshotDeploymentRepository>
                        local-nexus-snapshots::default::http://1.12.3.137:900/repository/maven-snapshots/
                    </altSnapshotDeploymentRepository>
                </properties>
                <repositories>
                    <repository>
                        <id>local-nexus-releases</id>
                        <url>http://1.12.3.137:900/repository/maven-releases/</url>
                        <releases>
                            <enabled>true</enabled>
                        </releases>
                        <snapshots>
                            <enabled>false</enabled>
                        </snapshots>
                    </repository>
                    <repository>
                        <id>local-nexus-snapshots</id>
                        <url>http://1.12.3.137:900/repository/maven-snapshots/</url>
                        <releases>
                            <enabled>false</enabled>
                        </releases>
                        <snapshots>
                            <enabled>true</enabled>
                        </snapshots>
                    </repository>
                </repositories>
                <pluginRepositories>
                    <pluginRepository>
                        <id>local-nexus-releases</id>
                        <url>http://1.12.3.137:900/repository/maven-releases/</url>
                        <releases>
                            <enabled>true</enabled>
                        </releases>
                        <snapshots>
                            <enabled>false</enabled>
                        </snapshots>
                    </pluginRepository>
                    <pluginRepository>
                        <id>local-nexus-snapshots</id>
                        <url>http://1.12.3.137:900/repository/maven-snapshots/</url>
                        <releases>
                            <enabled>false</enabled>
                        </releases>
                        <snapshots>
                            <enabled>true</enabled>
                        </snapshots>
                    </pluginRepository>
                </pluginRepositories>
            </profile>
        </profiles>
        <activeProfiles>
            <activeProfile>local-nexus</activeProfile>
        </activeProfiles>
    </settings>
    
  5. 部署完成

    通过mvn install/deploy 进行包的下载和发布

  6. 私服数据备份及迁移:1. 备份复制docker挂载的目录 2. 在新的机器或环境复制数据,脚本启动即可完成备份或迁移。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值