Maven配置国内镜像仓库和本地仓库

news2024/9/29 11:24:51

参考文章:IDEA配置Maven教程(超详细版~)_idea maven配置教程-CSDN博客

1.找到Maven的 settings.xml文件

我的按照路径是:C:\Program Files\Java\apache-maven-3.9.8\conf

2.打开settings.xml文件

我的打开是这个样子

3.增加本地仓库

在根节点【<settings >】下找到【<localRepository>】节点

个人建议先搜索一般文件都会有,只是被注释了

我的长这样

  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->

如果没有找到【<localRepository>】节点,

可以直接在【<settings >】下增加【<localRepository>】节点,

效果如下:

代码

  <!--本地仓库位置-->
  <localRepository>G:/1CodeTest/Java/Maven/Repository</localRepository>

4.增加国内镜像仓库

然后要注意需要在mirrors标签里加上阿里云镜像,因为这会大大提高我们下载依赖的速度

阿里的Maven官方:仓库服务

https://developer.aliyun.com/mvn/guide

阿里云云效 Maven 是什么

阿里云Maven中央仓库为 阿里云云效 提供的公共代理仓库,帮助研发人员提高研发生产效率,使用阿里云Maven中央仓库作为下载源,速度更快更稳定。

阿里云云效 是企业级一站式 DevOps 平台,覆盖产品从需求到运营的研发全生命周期,其中云效也提供了免费、可靠的Maven私有仓库 Packages 和代码管理仓库 Codeup,欢迎您体验使用。

云效制品仓库 Packages 致力于帮助开发者统一管理各种开发语言在开发、构建过程中的依赖,构建成果(二进制制品)以及交付过程关键信息的重要组件。

云效代码管理 Codeup 是阿里云出品的一款企业级代码管理平台,提供代码托管、代码评审、代码扫描、代码度量等功能,不限人数、超大容量且免费使用,全方位保护代码资产,帮助团队实现安全、稳定、高效的研发管理。

注意下面这个表格,我写的日期是2024-8-2

仓库名称阿里云仓库地址阿里云仓库地址(老版)源地址
centralhttps://maven.aliyun.com/repository/centralhttps://maven.aliyun.com/nexus/content/repositories/centralCentral Repository:
publichttps://maven.aliyun.com/repository/publichttps://maven.aliyun.com/nexus/content/groups/publiccentral仓和jcenter仓的聚合仓
gradle-pluginhttps://maven.aliyun.com/repository/gradle-pluginhttps://maven.aliyun.com/nexus/content/repositories/gradle-pluginhttps://plugins.gradle.org/m2/
apache snapshotshttps://maven.aliyun.com/repository/apache-snapshotshttps://maven.aliyun.com/nexus/content/repositories/apache-snapshotsIndex of /groups/snapshots

在节点【<mirrors >】下找到【<mirror>】节点

效果如下:

代码:

	<mirror>
      <id>alimaven</id>
      <mirrorOf>central</mirrorOf>
      <name>aliyunMaven</name>
      <url>https://maven.aliyun.com/nexus/content/groups/public</url> 
    </mirror>

5.settings.xml源码全文

<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<!--
 | This is the configuration file for Maven. It can be specified at two levels:
 |
 |  1. User Level. This settings.xml file provides configuration for a single user,
 |                 and is normally provided in ${user.home}/.m2/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -s /path/to/user/settings.xml
 |
 |  2. Global Level. This settings.xml file provides configuration for all Maven
 |                 users on a machine (assuming they're all using the same Maven
 |                 installation). It's normally provided in
 |                 ${maven.conf}/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -gs /path/to/global/settings.xml
 |
 | The sections in this sample file are intended to give you a running start at
 | getting the most out of your Maven installation. Where appropriate, the default
 | values (values used when the setting is not specified) are provided.
 |
 |-->
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">
  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
  <!--本地仓库位置-->
  <localRepository>G:/1CodeTest/Java/Maven/Repository</localRepository>
  <!-- interactiveMode
   | This will determine whether maven prompts you when it needs input. If set to false,
   | maven will use a sensible default value, perhaps based on some other setting, for
   | the parameter in question.
   |
   | Default: true
  <interactiveMode>true</interactiveMode>
  -->

  <!-- offline
   | Determines whether maven should attempt to connect to the network when executing a build.
   | This will have an effect on artifact downloads, artifact deployment, and others.
   |
   | Default: false
  <offline>false</offline>
  -->

  <!-- pluginGroups
   | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
   | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
   | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
   |-->
  <pluginGroups>
    <!-- pluginGroup
     | Specifies a further group identifier to use for plugin lookup.
    <pluginGroup>com.your.plugins</pluginGroup>
    -->
  </pluginGroups>

  <!-- TODO Since when can proxies be selected as depicted? -->
  <!-- proxies
   | This is a list of proxies which can be used on this machine to connect to the network.
   | Unless otherwise specified (by system property or command-line switch), the first proxy
   | specification in this list marked as active will be used.
   |-->
  <proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     |
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
    -->
  </proxies>

  <!-- servers
   | This is a list of authentication profiles, keyed by the server-id used within the system.
   | Authentication profiles can be used whenever maven must make a connection to a remote server.
   |-->
  <servers>
    <!-- server
     | Specifies the authentication information to use when connecting to a particular server, identified by
     | a unique name within the system (referred to by the 'id' attribute below).
     |
     | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
     |       used together.
     |
    <server>
      <id>deploymentRepo</id>
      <username>repouser</username>
      <password>repopwd</password>
    </server>
    -->

    <!-- Another sample, using keys to authenticate.
    <server>
      <id>siteServer</id>
      <privateKey>/path/to/private/key</privateKey>
      <passphrase>optional; leave empty if not used.</passphrase>
    </server>
    -->
  </servers>

  <!-- mirrors
   | This is a list of mirrors to be used in downloading artifacts from remote repositories.
   |
   | It works like this: a POM may declare a repository to use in resolving certain artifacts.
   | However, this repository may have problems with heavy traffic at times, so people have mirrored
   | it to several places.
   |
   | That repository definition will have a unique id, so we can create a mirror reference for that
   | repository, to be used as an alternate download site. The mirror site will be the preferred
   | server for that repository.
   |-->
  <mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
	 
	<mirror>
      <id>alimaven</id>
      <mirrorOf>central</mirrorOf>
      <name>aliyunMaven</name>
      <url>https://maven.aliyun.com/nexus/content/groups/public</url> 
    </mirror>
	
	 <mirror>
      <id>maven-default-http-blocker</id>
      <mirrorOf>external:http:*</mirrorOf>
      <name>Pseudo repository to mirror external repositories initially using HTTP.</name>
      <url>http://0.0.0.0/</url>
      <blocked>true</blocked>
    </mirror>
	
  
  </mirrors>

  <!-- profiles
   | This is a list of profiles which can be activated in a variety of ways, and which can modify
   | the build process. Profiles provided in the settings.xml are intended to provide local machine-
   | specific paths and repository locations which allow the build to work in the local environment.
   |
   | For example, if you have an integration testing plugin - like cactus - that needs to know where
   | your Tomcat instance is installed, you can provide a variable here such that the variable is
   | dereferenced during the build process to configure the cactus plugin.
   |
   | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
   | section of this document (settings.xml) - will be discussed later. Another way essentially
   | relies on the detection of a property, either matching a particular value for the property,
   | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
   | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
   | Finally, the list of active profiles can be specified directly from the command line.
   |
   | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
   |       repositories, plugin repositories, and free-form properties to be used as configuration
   |       variables for plugins in the POM.
   |
   |-->
  <profiles>
    <!-- profile
     | Specifies a set of introductions to the build process, to be activated using one or more of the
     | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
     | or the command line, profiles have to have an ID that is unique.
     |
     | An encouraged best practice for profile identification is to use a consistent naming convention
     | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
     | This will make it more intuitive to understand what the set of introduced profiles is attempting
     | to accomplish, particularly when you only have a list of profile id's for debug.
     |
     | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
    <profile>
      <id>jdk-1.4</id>

      <activation>
        <jdk>1.4</jdk>
      </activation>

      <repositories>
        <repository>
          <id>jdk14</id>
          <name>Repository for JDK 1.4 builds</name>
          <url>http://www.myhost.com/maven/jdk14</url>
          <layout>default</layout>
          <snapshotPolicy>always</snapshotPolicy>
        </repository>
      </repositories>
    </profile>
    -->

    <!--
     | Here is another profile, activated by the property 'target-env' with a value of 'dev', which
     | provides a specific path to the Tomcat instance. To use this, your plugin configuration might
     | hypothetically look like:
     |
     | ...
     | <plugin>
     |   <groupId>org.myco.myplugins</groupId>
     |   <artifactId>myplugin</artifactId>
     |
     |   <configuration>
     |     <tomcatLocation>${tomcatPath}</tomcatLocation>
     |   </configuration>
     | </plugin>
     | ...
     |
     | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
     |       anything, you could just leave off the <value/> inside the activation-property.
     |
    <profile>
      <id>env-dev</id>

      <activation>
        <property>
          <name>target-env</name>
          <value>dev</value>
        </property>
      </activation>

      <properties>
        <tomcatPath>/path/to/tomcat/instance</tomcatPath>
      </properties>
    </profile>
    -->
  </profiles>

  <!-- activeProfiles
   | List of profiles that are active for all builds.
   |
  <activeProfiles>
    <activeProfile>alwaysActiveProfile</activeProfile>
    <activeProfile>anotherAlwaysActiveProfile</activeProfile>
  </activeProfiles>
  -->
</settings>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1980405.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

简单的docker学习 第12章 Docker Swarm

第12章 Docker Swarm 12.1 swarm 理论基础 12.1.1 简介 Docker Swarm 是由 Docker 公司推出的 Docker 的原生集群管理系统&#xff0c;它将一个 Docker主机池变成了一个单独的虚拟主机&#xff0c;用户只需通过简单的 API 即可实现与 Docker 集群的通信。Docker Swarm 使用 …

护眼大路灯哪个牌子好?2024学生护眼大路灯推荐

护眼大路灯哪个牌子好&#xff1f;护眼大路灯不仅能够提供日常的光线照明&#xff0c;还模拟了太阳光光线&#xff0c;使在室内用眼学习也能够有着自然光般的舒适感&#xff0c;但现在市场上有许多对产品质量把控不过关、光线效果欠佳、存有安全隐患的劣质护眼大路灯产品&#…

MySQL索引及索引的优化策略

1.什么是索引&#xff1f; 索引是对数据库表中一列或多列的值进行排序的一种结构&#xff0c;使用索引可快速访问数据库表中的特定信息 2.为什么使用索引&#xff1a; 1.高效性&#xff1a;利用索引可以提高数据库的查询效率 2.唯一性&#xff1a;索引可以确保所查的数据的唯一…

【已解决】没有密码,如何解除PPT的“只读方式”?

PPT可以设置有密码的“只读方式”&#xff0c;保护文件不被随意编辑更改。 在设置保护后&#xff0c;打开PPT时就会弹出对话框&#xff0c;提示需要“输入密码以修改或以只读方式打开”&#xff0c;也就是输入密码才能编辑修改PPT&#xff0c;如果点击“只读”也能打开文件&am…

2025浙江(杭州)国际安防产品展览会(浙江安博会)

2025浙江&#xff08;杭州&#xff09;国际智慧城市与安防产品展览会 2025hangzhou smart city And Security Expo 时间:2025年4月23-25日 地点:杭州国际博览中心 展会介绍 浙江&#xff08;杭州&#xff09;国际智慧城市及安防产品博览会&#xff08;简称:浙江安博会&#…

探索AutoGGUF:新时代的量化工具

大家好&#xff01;今天我非常激动地向大家介绍一款新工具&#xff0c;叫做AutoGGUF。AutoGGUF是一款全新的图形用户界面&#xff0c;它是用Python语言编写的&#xff0c;基于PyQt6库。PyQt6是Python的一种绑定&#xff0c;用于创建图形用户界面。而AutoGGUF的设计初衷是简化使…

docker 安装 geoserver

docker 安装 geoserver 文章目录 docker 安装 geoserver一、准备工作二、创建容器三、安装插件3.1 插件下载3.2 将插件拷贝进容器3.3 创建新镜像 四、配置 nginx 代理 一、准备工作 # 获取最新镜像 docker pull kartoza/geoserver#创建数据持久化目录 /usr/local/application/…

大模型RAG实战|文本转换:文本分割器、中文标题增强与高级提取管道

ThinkRAG大模型RAG实战系列文章&#xff0c;带你深入探索使用LlamaIndex框架&#xff0c;构建本地大模型知识库问答系统。本系列涵盖知识库管理、检索优化、模型本地部署等主题&#xff0c;通过代码与实例&#xff0c;讲解如何打造生产级系统&#xff0c;实现本地知识库的快速检…

抽象代数精解【8】

文章目录 希尔密码矩阵矩阵基本概念行列式基本概念特殊矩阵关于乘法运算构成群 加解密原理密钥加密函数解密函数 Z 26 上的运算&#xff08; Z 256 与此类似&#xff09; Z_{26}上的运算&#xff08;Z_{256}与此类似&#xff09; Z26​上的运算&#xff08;Z256​与此类似&…

一篇模块化RAG之最新全面系统性综述

RAG访问外部知识库增强了LLMs处理知识密集型任务的能力&#xff0c;随着应用场景需求的增加&#xff0c;RAG系统变得更加复杂。传统的RAG依赖于简单的相似性检索&#xff0c;**面对复杂查询和变化多端的文本块时表现不佳&#xff1a;**对查询的浅层理解、检索冗余和噪声。 朴素…

Elasticsearch未授权访问漏洞

ElasticSearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索】擎&#xff0c;基于RESTful web:接口。Elasticsearch:是用Java开发的&#xff0c;并作为Apache许可条款下的开放源码发布&#xff0c;是当前流行的企业级搜索引擎。Elasticsearch的增别改…

Spring File Storage(文件的对象存储)框架基本使用指南

概述 本文仅作为快速入门&#xff0c;深入学习及使用详见官网 云存储 在开发过程当中&#xff0c;会使用到存文档、图片、视频、音频等等&#xff0c;这些都会涉及存储的问题&#xff0c;文件可以直接存服务器&#xff0c;但需要考虑带宽和存储空间&#xff0c;另外一种方式…

扑翼无人机仿生鸟技术详解

1. 仿生学原理 扑翼无人机仿生鸟技术&#xff0c;顾名思义&#xff0c;是受到自然界鸟类飞行机制的深刻启发而发展起来的一种无人机技术。仿生学原理在此技术中扮演着核心角色&#xff0c;它通过研究鸟类的翅膀结构、飞行姿态、气动效率、能量转换等生物学特性&#xff0c;力求…

Python酷库之旅-第三方库Pandas(066)

目录 一、用法精讲 261、pandas.Series.dt.year属性 261-1、语法 261-2、参数 261-3、功能 261-4、返回值 261-5、说明 261-6、用法 261-6-1、数据准备 261-6-2、代码示例 261-6-3、结果输出 262、pandas.Series.dt.month属性 262-1、语法 262-2、参数 262-3、功…

Hibernate Validator 数据校验框架

文章目录 一、数据校验框架简介1、JSR(Java 规范提案)&#xff1a;Bean Validation2、javax.validation.api3、jakarta.validation.api 二、SpringBoot基础使用1、校验get请求参数2、校验post请求参数3、常用注解4、分组校验5、自定义校验规则5、校验模式6、全局异常处理 一、数…

LabVIEW远程开发

LabVIEW远程开发是指在不同地点的开发者通过网络协同工作&#xff0c;共同开发、调试和维护基于LabVIEW的应用程序。这种开发模式适用于分布式团队、远程办公和全球化项目合作&#xff0c;能够有效利用不同地区的人才和资源。以下是LabVIEW远程开发的详细介绍&#xff1a; 1. 远…

elasticsearch的使用(二)

DSL查询 Elasticsearch的查询可以分为两大类&#xff1a; 叶子查询&#xff08;Leaf query clauses&#xff09;&#xff1a;一般是在特定的字段里查询特定值&#xff0c;属于简单查询&#xff0c;很少单独使用。 复合查询&#xff08;Compound query clauses&#xff09;&am…

C语言程序设计-[4] 算法和程序结构

1、算法 一个程序至少包含两个方面&#xff1a;数据结构和算法&#xff0c;算法就是为解决一个问题而采取的方法和步骤&#xff0c;即对程序操作步骤的描述。 算法有一定的评价标准和表示方法&#xff0c;其中流程图法和N-S结构图法是本章需要介绍的两种方法。 &#xff08;…

校园商铺管理小程序的设计

管理员账户功能包括&#xff1a;系统首页&#xff0c;个人中心&#xff0c;用户管理&#xff0c;商家管理&#xff0c;商品类型管理&#xff0c;商品信息管理&#xff0c;在线咨询管理&#xff0c;咨询回复管理&#xff0c;交流论坛&#xff0c;系统管理 微信端账号功能包括&a…

LabVIEW工件表面瑕疵识别系统

开发了一种利用LabVIEW和IMAQ Vision视觉工具进行工件表面瑕疵识别的系统。该系统通过图像处理技术识别并分类工件表面的裂纹、划痕等缺陷&#xff0c;从而提升生产线的分拣效率和产品质量。 项目背景 工业生产中&#xff0c;工件表面的缺陷直接影响产品质量和生产效率。传统人…