搭建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版本+虚拟机参数配置说明)
1083 0
|
敏捷开发 Java 持续交付
阿里云云效产品使用合集之maven仓库是否可以代替自建的Nexus
云效作为一款全面覆盖研发全生命周期管理的云端效能平台,致力于帮助企业实现高效协同、敏捷研发和持续交付。本合集收集整理了用户在使用云效过程中遇到的常见问题,问题涉及项目创建与管理、需求规划与迭代、代码托管与版本控制、自动化测试、持续集成与发布等方面。
|
数据安全/隐私保护 Docker 容器
docker 部署nexus
要在Docker上部署Nexus,可以按照以下步骤进行操作: 1. 确保已经安装并配置好Docker。可以在官方网站(https://www.docker.com/)上找到适合你操作系统的安装程序,并按照说明进行安装。 2. 搜索并下载Nexus的Docker镜像。在Docker Hub上搜索"Nexus",找到Sonatype官方提供的Nexus Repository Manager的镜像。 3. 使用以下命令从Docker Hub上下载Nexus镜像: ``` docker pull sonatype/nexus3 ``` 4. 运行Nexus容器。使用以下命令创建并运行一个名为"
1403 0
|
Oracle Java 关系型数据库
Maven私服Nexus配置
Maven私服Nexus配置
1308 0
|
Java Linux Maven
nexus搭建maven私有仓库
nexus搭建maven私有仓库
761 4
nexus搭建maven私有仓库
|
缓存 运维 负载均衡
阿里云云效操作报错合集之在获取Maven私有库配置出错,该如何操作
本合集将整理呈现用户在使用过程中遇到的报错及其对应的解决办法,包括但不限于账户权限设置错误、项目配置不正确、代码提交冲突、构建任务执行失败、测试环境异常、需求流转阻塞等问题。阿里云云效是一站式企业级研发协同和DevOps平台,为企业提供从需求规划、开发、测试、发布到运维、运营的全流程端到端服务和工具支撑,致力于提升企业的研发效能和创新能力。
|
Linux 网络安全 数据安全/隐私保护
【Nexus】Linux安装Nexus
【Nexus】Linux安装Nexus
|
JavaScript Java 测试技术
从零开始:Nexus私服搭建与Maven仓库配置的完全指南
从零开始:Nexus私服搭建与Maven仓库配置的完全指南
22490 7
|
存储 Java Linux
Nexus【部署 01】CentOS 7.5 环境下搭建私有Maven仓库实录(启动问题处理+安装文件 nexus-3.4.0-02-unix.tar.gz 云盘链接)
Nexus【部署 01】CentOS 7.5 环境下搭建私有Maven仓库实录(启动问题处理+安装文件 nexus-3.4.0-02-unix.tar.gz 云盘链接)
750 0
|
Java Maven 数据安全/隐私保护
nexus私服踩坑
nexus私服踩坑

热门文章

最新文章