搭建nexus私服

简介: 搭建nexus私服

1、官方安装文档

2、Docker 环境下搭建nexus私服  (主要参考)

3、 sonatype/nexus3(docker hub)

4、使用Nexus搭建Maven私服

5、ubuntu下使用Nexus搭建Maven私服

6、Linux (Ubuntu)安装nexus,搭建maven私有服务器

7、Nexus 3.x 安装/配置/使用

8、https://help.sonatype.com/repomanager3/user-interface/working-with-your-user-profile

9、Nexus3.x安装及配置

10、Nexus仓库搭建及配置详解  (参考三)

11、Nexus私服搭建及settings.xml配置详细教程  (参考一)

12、nexus私服搭建及信息配置 (参考二)

13、【Maven】---Nexus私服配置Setting和Pom (参考四)

安装nexus3

1、查找镜像

docker search nexus

一般安装star数最多的版本,目前最新是sonatype/nexus3

2、拉取镜像

docker pull sonatype/nexus3

3、启动镜像

 

#指定虚拟机与容器共享的文件夹
mkdir /usr/local/docker/nexus/nexus-data
 
#指定数据卷后启动,可能会报一些权限错误,导致启动不起来。可能会需要修改文件夹权限
chmod 777 /usr/local/docker/nexus/nexus-data
 
#启动容器
docker run -p 8081:8081 --name nexus -v /usr/local/docker/nexus/nexus-data:/nexus-data snoatype/nexus3

创建阿里云Proxy仓库

1、Repository-->Repositories-->Create repository-->maven2(proxy)

附阿里云中央仓库地址:http://maven.aliyun.com/nexus/content/groups/public/

2、配置仓库组(默认已有一个maven-public):

把刚创建的阿里仓库加入maven-public仓库组

Repository-->Repositories-->Create repository-->maven2(group)

注:注意仓库顺序。maven查找依赖时会依次遍历仓库组中的仓库。

 

在Maven 中使用Nexus

为了能让本机所有的Maven项目都使用Nexus本地仓库,需要对settings.xml文件进行修改,但setting.xml并不支持直接配置repositories和pluginRepositories,因此需要使用Maven提供的Profile机制,将仓库配置放到setting.xml中的Profile中。代码清单如下:

<?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">
    <servers>
        <!-- 设置私库认证信息(访问) -->
        <server>
            <id>insuresmart-nexus</id>
            <username>admin</username>
            <password>admin</password>
        </server>
 
        <!-- 设置私库认证信息(发布) -->
        <server>
            <id>insuresmart-nexus-releases</id>
            <username>admin</username>
            <password>admin</password>
        </server>
 
        <server>
            <id>insuresmart-nexus-snapshots</id>
            <username>admin</username>
            <password>admin</password>
        </server>
    </servers>
 
    <!--设置私库mirror 表示maven所有的请求都由nexus来处理 -->
    <mirrors>
        <mirror>
            <id>insuresmart-nexus</id>
            <name>Yitong Nexus Repository</name>
            <mirrorOf>*</mirrorOf>
            <url>http://192.168.124.125:8081/repository/maven-public/</url>
        </mirror>
    </mirrors>
 
    <!--设置maven私库信息 -->
    <profiles>
        <profile>
            <id>insuresmart-nexus</id>
            <repositories>
                <repository>
                    <id>insuresmart-nexus</id>
                    <name>insuresmart nexus repository</name>
                    <url>http://192.168.124.125:8081/repository/maven-public/</url>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>insuresmart-nexus</id>
                    <name>insuresmart nexus repository</name>
                    <url>http://192.168.124.125:8081/repository/maven-public/</url>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                </pluginRepository>
            </pluginRepositories>
        </profile>
 
        <!--覆盖maven中央仓库设置开启releases和snapshots版本的下载-->
        <profile>
            <id>central</id>
            <repositories>
                <repository>
                    <id>central</id>
                    <url>http://central</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>central</id>
                    <url>http://central</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
 
    <!--激活私库信息的配置 -->
    <activeProfiles>
        <activeProfile>insuresmart-nexus</activeProfile>
        <activeProfile>central</activeProfile>
    </activeProfiles>
</settings>

pom.xml文件配置

    <!--当前项目发布到远程仓库中-->
    <distributionManagement>
        <repository>
            <id>insuresmart-nexus-releases</id>
            <name>insuresmart-nexus-releases</name>
            <url>http://192.168.124.125:8081/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>insuresmart-nexus-snapshots</id>
            <name>insuresmart-nexus-snapshots</name>
            <url>http://192.168.124.125:8081/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

标签id的值必须与setting文件中server标签中的值一致。

 

然后在需要部署的文件上使用 mvn clean deploy  部署到nexus私服上。

 

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

部署

然后在需要部署的文件上使用 mvn clean deploy  部署到nexus私服上。

IntelliJ IDEA 可以直接使用Maven下的deploy进行部署




备注:install 是安装到本地仓库,也即本机如:C:\Users\Admin\.m2\repository\里

参考:

1、Nexus仓库搭建及配置详解

2、Nexus私服搭建及settings.xml配置详细教程

3、nexus私服搭建及信息配置

4、【Maven】---Nexus私服配置Setting和Pom

目录
相关文章
|
Web App开发 Java Linux
Nexus【部署 02】最新版本 nexus-3.35.0-02-unix.tar.gz 安装配置启动及测试(JDK版本+虚拟机参数配置说明)
Nexus【部署 02】最新版本 nexus-3.35.0-02-unix.tar.gz 安装配置启动及测试(JDK版本+虚拟机参数配置说明)
1609 0
|
9月前
|
存储 缓存 应用服务中间件
手把手教你 Nexus 配置 Docker 镜像源|内网提速超简单
在团队开发和内网部署场景中,反复从公网拉取Docker镜像不仅耗时耗流量,还容易受网络波动影响效率。Nexus私服+轩辕镜像的组合,既能实现内网镜像缓存复用,又能借助稳定的镜像源解决拉取慢、失败的问题,堪称内网镜像管理的最优解。
1217 5
手把手教你 Nexus 配置 Docker 镜像源|内网提速超简单
|
Docker 容器
docker出现问题:启动nexus时报错mkdir: cannot create directory ‘../sonatype-work/nexus3‘: Permission denied解决方案
docker出现问题:启动nexus时报错mkdir: cannot create directory ‘../sonatype-work/nexus3‘: Permission denied解决方案
2186 0
docker出现问题:启动nexus时报错mkdir: cannot create directory ‘../sonatype-work/nexus3‘: Permission denied解决方案
|
12月前
|
Java Maven 数据安全/隐私保护
Nexus仓库
Nexus是一款开源仓库管理工具,支持Maven、NPM、Docker等格式。本文介绍其在Linux与Docker环境下的安装配置,包括JDK部署、OSS版下载、仓库创建、用户权限管理及密码重置方法,并涵盖私服搭建、持久化存储、资源上传与匿名访问设置,助力企业高效构建私有仓库体系。
|
12月前
|
Java Maven 数据安全/隐私保护
06-nexus私仓环境搭建
本文介绍Nexus Repository Manager OSS版的安装与配置,包括JDK环境准备、Nexus部署、用户创建、启动服务及Web界面登录。详细说明如何搭建Maven、Docker私仓,实现Jar包上传、本地仓库迁移、项目配置使用私仓,以及Docker镜像的推送拉取。同时简述npm、helm等其他类型仓库的启用方法,适用于企业级制品管理。
|
12月前
|
网络协议 关系型数据库 MySQL
nexus搭建docker私仓 使用nexus创建docker私有仓库
本文介绍如何使用Nexus搭建Docker私有仓库,包括Nexus中启用Docker仓库、创建Blob存储、配置docker-hosted仓库及端口设置,并说明防火墙开放与Docker客户端配置insecure-registry的方法,实现镜像的推送与拉取。
1100 0
|
12月前
|
Java Maven 数据安全/隐私保护
nexus私仓环境搭建
本文介绍Nexus Repository Manager OSS的安装与配置,包括JDK环境准备、Nexus下载解压、用户创建及服务启动。详细说明如何配置Maven、Docker私仓,实现jar包上传与镜像推送,并支持匿名访问。同时涵盖npm、helm等仓库的搭建要点,适用于企业级私有化部署需求。(239字)
967 0
|
12月前
|
Java Maven 数据安全/隐私保护
06-nexus私仓环境搭建
本文详细介绍Nexus Repository Manager OSS的安装与配置,涵盖JDK环境准备、服务部署、用户创建及启动操作。指导用户搭建Maven和Docker私有仓库,实现jar包与镜像的上传下载,并配置匿名访问与本地客户端信任。支持多种仓库类型,适用于企业级制品管理。
620 0
|
监控 调度 数据库
简化任务调度与管理:详解XXL-Job及Docker Compose安装
在现代应用程序开发中,任务调度和管理是至关重要的一部分。XXL-Job是一个强大的分布式任务调度平台,它使得任务的调度和管理变得更加轻松和高效。本文将介绍XXL-Job的基本概念,并详细演示如何使用Docker Compose进行快速安装和配置。
1476 1
简化任务调度与管理:详解XXL-Job及Docker Compose安装
|
Java Linux 网络安全
在Linux上搭建Maven仓库的实战教程
在Linux上搭建Maven仓库的实战教程
1475 0