Maven 镜像源加速和私服配置

简介: 华为开源镜像站加速下载开源组件settings.xml 在 mirrors 标签中添加 mirror 子节点:

华为开源镜像站加速下载开源组件


settings.xml 在 mirrors 标签中添加 mirror 子节点:

<mirror>
        <id>huawei-cloud-mirror</id>
        <mirrorOf>central</mirrorOf>
        <url>https://repo.huaweicloud.com/repository/maven/</url>
</mirror>


配置华为私有库下载


  1. settings.xml 中设置仓库凭证:servers 节点中添加如下配置

<server>
        <id>releases</id>
        <username>************</username>
        <password>************</password>
    </server>
    <server>
        <id>snapshots</id>
        <username>************</username>
        <password>************</password>
    </server>


  1. 在 profiles 节点中添加如下配置。并需要在 settings.xml 文件<activeProfiles>标签中启用。

<profile>
        <id>MyProfile</id>
        <repositories>
            <repository>
                <id>releases</id>
                <url>https://devrepo.devcloud.cn-north-4.huaweicloud.com/07/nexus/content/repositories/088dbeef3980f4050f6fc007779eab60_1_0/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
            </repository>
            <repository>
                <id>snapshots</id>
                <url>https://devrepo.devcloud.cn-north-4.huaweicloud.com/07/nexus/content/repositories/088dbeef3980f4050f6fc007779eab60_2_0/</url>
                <releases>
                    <enabled>false</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
        </repositories>
    </profile>


阿里云开源镜像站加速下载开源组件


在<mirrors></mirrors>标签中添加mirror子节点,

<mirror>
            <id>aliyun-mirror</id>
            <mirrorOf>central</mirrorOf>
            <url>https://maven.aliyun.com/repository/public</url>
</mirror>


如果想使用其它代理仓库,可在 profile 下的 repositories 节点中加入对应的仓库使用地址。以使用 Spring 代理仓为例:

<repository>
    <id>spring</id>
    <url>https://maven.aliyun.com/repository/spring</url>
    <releases>
        <enabled>true</enabled>
    </releases>
    <snapshots>
        <enabled>true</enabled>
    </snapshots>
</repository>


配置华为私有库下载



  1. 在 settings.xml 中添加认证信息


  在 Maven 默认 settings.xml 中找到 servers 的部分,添加一个 server 配置如下。

<servers>
    <server>
        <id>rdc-releases</id>
        <username>***</username>
        <password>******</password>
    </server>
    <server>
        <id>rdc-snapshots</id>
        <username>***</username>
        <password>******</password>
    </server>
</servers>


  1. 在 profiles 节点添加如下配置, 其中 repository 是顺序搜索下载包的.

<profile>
            <id>rdc-private-repo</id>
            <repositories>
                <repository>
                    <id>rdc-releases</id>
                    <url>https://repo.rdc.aliyun.com/repository/78947-release-CfzLQ7/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </repository>
                <repository>
                    <id>rdc-snapshots</id>
                    <url>https://repo.rdc.aliyun.com/repository/78947-snapshot-XtuBsZ/</url>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>rdc-releases</id>
                    <url>https://repo.rdc.aliyun.com/repository/78947-release-CfzLQ7/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                </pluginRepository>
                <pluginRepository>
                    <id>rdc-snapshots</id>
                    <url>https://repo.rdc.aliyun.com/repository/78947-snapshot-XtuBsZ/</url>
                    <releases>
                        <enabled>false</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>


使用 properties 简化 url 配置


<?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>huawei-yun-mirror</id>
            <mirrorOf>central</mirrorOf>                        
            <url>https://repo.huaweicloud.com/repository/maven/</url>
        </mirror>
    </mirrors>
    <profiles>
        <profile>
            <id>my-profile</id>
            <properties>
                <my.repo.url>---------YOUE_URL---------</my.repo.url>
            </properties>
            <repositories>
                <repository>
                    <id>my-repo</id>
                    <url>${my.repo.url}</url>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <id>my-repo</id>
                    <url>${my.repo.url}</url>
                </pluginRepository>
            </pluginRepositories>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>my-profile</activeProfile>
    </activeProfiles>
</settings>


拉取制品



mvn clean package


参考



华为开源镜像站软件开发服务华为云


https://mirrors.huaweicloud.com/home


Maven 仓库 · 云效 Packages · 企业级制品仓库 https://packages.aliyun.com/maven


Maven 查看当前生效配置、pom、环境变量等命令(mvn help用法) - 简书


https://www.jianshu.com/p/6184fa25fd53



目录
相关文章
|
2月前
|
Java Maven
2022最新版超详细的Maven下载配置教程、IDEA中集成maven(包含图解过程)、以及导入项目时jar包下载不成功的问题解决
这篇文章是一份关于Maven的安装和配置指南,包括下载、环境变量设置、配置文件修改、IDEA集成Maven以及解决jar包下载问题的方法。
2022最新版超详细的Maven下载配置教程、IDEA中集成maven(包含图解过程)、以及导入项目时jar包下载不成功的问题解决
|
2月前
|
Java Maven
解决idea每次新建maven项目都需要重新配置maven的问题
解决idea每次新建maven项目都需要重新配置maven的问题
95 1
|
3月前
|
Java Maven 编译器
Java编译器注解运行和自动生成代码问题之@AutoService工作问题如何解决
Java编译器注解运行和自动生成代码问题之@AutoService工作问题如何解决
140 1
|
7天前
|
XML Java Maven
idea配置maven步骤及常见问题
本文介绍了在IDEA中配置Maven的详细步骤,包括Maven的下载、系统环境变量的配置、Maven本地仓库的设置、镜像加速的配置,以及在IDEA中指定Maven路径和配置文件。同时,还提供了解决每次新建项目需要重新手动配置Maven问题的方法。
idea配置maven步骤及常见问题
|
2月前
|
安全 Java Maven
优化Maven镜像配置:使用阿里云加速依赖下载
更新Maven镜像配置至关重要,尤其使用阿里云仓库时。在`settings.xml`中加入特定镜像配置可显著提升依赖下载速度。示例配置指定了阿里云镜像ID、替代表态仓库、安全的URL、默认布局及启用版本管理。需定位至用户目录下的`.m2/`文件夹编辑`settings.xml`,添加镜像信息后保存测试。若下载仍慢,考虑网络状况或备选镜像。多镜像设置时需注意避免冲突。
170 3
|
2月前
|
Java 编译器 测试技术
项目管理工具Maven的简单配置示例
【8月更文挑战第11天】这段内容介绍了如何通过Maven快速搭建并配置一个Java项目。首先需确保已安装Maven,接着可通过命令行创建一个基础项目结构,定义`groupId`、`artifactId`等基本信息。项目根目录下的`pom.xml`文件是核心配置文件,用于声明依赖库如JUnit,并配置构建插件如Maven Compiler Plugin以指定Java编译版本。最后,通过执行`mvn clean install`命令完成项目的清理与构建。这个流程适合初学者快速上手Maven项目管理。
|
2月前
|
Java 应用服务中间件 Maven
Mac使用Idea配置传统SSM项目(非maven项目)
Mac使用Idea配置传统SSM项目(非maven项目)
38 1
|
3月前
|
Java Maven 开发者
入职必会-开发环境搭建14-IDEA配置Maven
在 IDEA 中配置 Maven 可以帮助开发者更方便地管理项目依赖、构建项目和部署应用程序。要在 IDEA 中配置 Maven,可以按照以下步骤进行。
入职必会-开发环境搭建14-IDEA配置Maven
|
2月前
|
Java Maven
成功解决IDEA中建立新项目Maven会默认选择配置(图解详细说明)
这篇文章提供了在IntelliJ IDEA中设置新项目的Maven配置的详细步骤,包括如何通过菜单路径进入设置,选择Maven配置,以及展示设置后的效果,还提供了Maven的安装教程和解决导入项目时jar包下载问题的方案。
成功解决IDEA中建立新项目Maven会默认选择配置(图解详细说明)
|
2月前
|
Java Maven
Mac Maven环境变量配置 zsh: command not found: mvn
Mac Maven环境变量配置 zsh: command not found: mvn
134 0

推荐镜像

更多
下一篇
无影云桌面