首页 > 其他分享 >maven设置多个镜像源,按顺序下载依赖

maven设置多个镜像源,按顺序下载依赖

时间:2022-08-24 17:38:30浏览次数:60  
标签:nexus1 顺序 http nexus maven nexus2 镜像 com

目标

分别配置两个nexus镜像源,目的: 编译时,先从nexus1尝试下载依赖,如果失败,到nexus2下载依赖,再失败,去公网中央仓库下载镜像

配置

settings.xml

<?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">

    <mirrors>
        <mirror>
            <id>nexus1</id>
            <mirrorOf>nexus1</mirrorOf>
            <url>http://nexus1.com/nexus/repository/maven-delivery/</url>
        </mirror>
        <mirror>
            <id>nexus2</id>
            <mirrorOf>nexus2</mirrorOf>
            <url>http://nexus2.com/repository/maven-public/</url>
        </mirror>
    </mirrors>

    <!-- 配置连接密钥,如果需要认证 -->
    <servers>
        <server>
            <id>nexus1</id>
            <username>demo</username>
            <password>demo001</password>
        </server>
    </servers>

    <!-- The resolution of multiple Repositories only works with profiles!-->
    <profiles>
        <profile>
            <id>nexus</id>
            <repositories>
                <repository>
                    <id>nexus1</id>
                    <url>http://nexus1.com/nexus/repository/maven-delivery/</url>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                </repository>
                <repository>
                    <id>nexus2</id>
                    <url>http://nexus2.com/repository/maven-public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>nexus1</id>
                    <url>http://nexus1.com/nexus/repository/maven-delivery/</url>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                </pluginRepository>
                <pluginRepository>
                    <id>nexus2</id>
                    <url>http://nexus2.com/repository/maven-public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>nexus</activeProfile>
    </activeProfiles>

</settings>

测试

使用mvn插件下载一个不存在的依赖,查看效果

mvn dependency:get -DgroupId=com.github.ggdefe -DartifactId=ggdefe -Dversion=1.0.0

输出


标签:nexus1,顺序,http,nexus,maven,nexus2,镜像,com
From: https://www.cnblogs.com/xiaojiluben/p/16620945.html

相关文章

  • el-checkbox实现拖动调整顺序
    1.下载插件npminstallawe-add--save2.在main.js中引入使用importVueDNDfrom'awe-dnd';Vue.use(VueDND);3.项目中使用<template><div>......
  • maven依赖管理的概念、仓库的种类和彼此关系
    maven依赖管理的概念图解: 仓库的种类和彼此关系 ......
  • 案例分析&环境搭建、maven概述
    案例分析&环境搭建案例需求:1,提供index.html页面,页面中有一个省份下拉列表2.当页面加载完成后发送ajax请求,加载所有省份   maven概述maven是什么项目管理工具M......
  • 词典遍历顺序
     funcmapKeyOrder(){ m:=map[int]struct{}{} fori:=0;i<16;i++{ m[i]=struct{}{} } fori:=0;i<16;i++{ l:=[]int{} fork:=range......
  • WSL2安装nvm并配置npm镜像源
    1、下载安装脚本并执行curl-o-https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh|bash2、关闭命令行后重新打开,输入以下内容验证,出现nvm即表示安......
  • maven项目不上传某些jar文件到私服
    maven项目,在顶层目录执行deploy命令时,默认会将所有的jar包全部上传到私服,实际上我们只需要上传接口jar文件即可。解决方案:在不需要上传的项目pom.xml文件中,加上如下即可。......
  • Docker安装Open LDAP并启用syncrepl镜像同步
    简单介绍如何快速通过docker启动openldap服务,并通过syncrepl机制实现目录数据的镜像复制。本文只涉及关键步骤,相关技术的入门请移步入门教程。所有本文的配置和脚本只针对b......
  • MAVEN学习笔记(二) IDEA中使用Maven
    IDEA中使用Maven在IDEA中配置MAVEN路径文件---->设置---->构建、执行、部署---->构建工具---->Maven找到主路径、用户设置文件、本地仓库并修改 继续在Maven下找到运......
  • STS用Maven写一个登录页面
    上一章我们写了一个HelloWorld,这一章在此基础上写出一个登录页面。 一、当前目录结构为:  之所以运行后出现HelloWord的页面,是因为server启动时会默认执行index.jsp......
  • Maven 仓库
    Maven仓库Maven仓库有三种类型:本地(local)中央(central)远程(remote)本地仓库Maven的本地仓库,在安装Maven后并不会创建,它是在第一次执行maven命令的时候才被创建......