maven 镜像问题

1、创建maven新项目时报错
[ERROR] Plugin org.apache.maven.plugins:maven-archetype-plugin:RELEASE or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-archetype-plugin:jar:RELEASE: Failed to resolve version for org.apache.maven.plugins:maven-archetype-plugin:jar:RELEASE: Could not find metadata org.apache.maven.plugins:maven-archetype-plugin/maven-metadata.xml in local (C:\Users\Administrator.m2\repository) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
[ERROR] Maven execution terminated abnormally (exit code 1)
2、加载带svn的项目时报错
Error:svn: E155013: Can’t add ‘F:\workspace\ProjectSpace\UnionPay\DataPlatform.idea\libraries\Maven__org_glassfish_javax_servlet_3_1.xml’ to a parent directory scheduled for deletion

解决方法:maven安装目录下的settings.xml配置文件没有配置镜像

 <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>
     -->   </mirrors>

这样需要的东西会从maven的中央仓库下载,因为这个仓库是在国外,所以有一些会下载失败

所以重新配置了一下仓库地址

 <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>
	  <name>aliyun maven</name>
	  <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
	  <mirrorOf>central</mirrorOf>        
	</mirror>
  </mirrors>

问题解决。在创建mvn项目时,注意设置,如图
在这里插入图片描述

### 如何配置 Maven 镜像 Maven 是一种强大的项目管理工具,在实际开发过程中,为了提高依赖下载速度,通常会通过配置镜像来优化性能。以下是关于如何配置 Maven 镜像以及一些常用的镜像地址。 #### 1. 配置 Maven 镜像的步骤 Maven镜像可以通过修改 `settings.xml` 文件实现。该文件一般位于两个地方: - **全局配置**:`${MAVEN_HOME}/conf/settings.xml` - **用户级配置**:`${USER_HOME}/.m2/settings.xml` 如果 `${USER_HOME}/.m2/` 下不存在 `settings.xml` 文件,则可以手动创建或者复制默认的 `settings.xml` 到此目录下[^4]。 在 `settings.xml` 中添加 `<mirrors>` 节点并定义具体的镜像信息。例如: ```xml <mirrors> <!-- 阿里云镜像 --> <mirror> <id>aliyunmaven</id> <mirrorOf>*</mirrorOf> <name>阿里云公共仓库</name> <url>https://maven.aliyun.com/repository/public</url> </mirror> <!-- 国内中央仓库镜像 --> <mirror> <id>maven.net.cn</id> <mirrorOf>central</mirrorOf> <name>Mirror from Maven in China</name> <url>http://maven.net.cn/content/groups/public/</url> </mirror> </mirrors> ``` 上述代码片段展示了两种常见的镜像配置方式,分别来自阿里云和中国本地化服务提供商[^3][^2]。 #### 2. 常见的 Maven 镜像地址列表 以下是一些国内外广泛使用的 Maven 镜像地址,可以根据网络环境选择适合的镜像: | ID | Name | URL | |------------------|--------------------------|----------------------------------------------------| | aliyunmaven | 阿里云公共仓库 | https://maven.aliyun.com/repository/public | | maven-net-cn | Maven 中国 | http://maven.net.cn/content/groups/public/ | | central | 默认中央仓库 | https://repo.maven.apache.org/maven2/ | | huaweicloud-mvn | 华为云 Maven | https://repo.huaweicloud.com/repository/maven/ | 这些镜像能够显著提升依赖项的下载效率,尤其是在国内访问国外资源较慢的情况下[^1]。 #### 3. IDEA 中配置 Maven 镜像 对于使用 IntelliJ IDEA 开发环境的开发者来说,可以直接在 IDE 设置中完成 Maven 镜像的配置。具体操作如下: - 打开 IDEA 并进入菜单栏中的 `File -> Settings -> Build, Execution, Deployment -> Build Tools -> Maven`。 - 在右侧窗口切换到 `Importing` 和 `Runner` 页面,确认所选的 `Settings file` 是否指向自定义的 `settings.xml` 文件。 - 如果未指定路径,默认情况下将采用 Maven 自带的全局配置文件[^3]。 --- ###
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值