mvn help:system 需要下载maven-clean-plugin或其他插件 但是连接不了远程仓库导致报错

问题描述

因为需要,想在机器A上搭建maven环境,由于机器A不能接入互联网,所以想把机器B上已有的仓库直接拷贝到A中使用。于是将机器B的整个repository压缩然后复制到机器A中,具体路径C:\.m2\repository。(机器B中可以正确的执行所有mvn命令,因为仓库很全)
然后给机器A中安装JDK、apache-maven-3.6.0,配置相关的环境变量,修改settings.xml中的本地仓库路径。
以上步骤完毕后,执行mvn -v 命令得到如下结果,说明maven安装没有问题。

C:\>mvn -v 
Maven home: D:\software\Apache\apache-maven-3.6.0\bin\..
Java version: 1.8.0_171, vendor: Oracle Corporation, runtime: D:\software\JDK\jdk1.8.0_171\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

此时,执行mvn help:system得到如下结果

C:\>mvn help:system
INFO] Scanning for projects...
Downloading from mirrorId: http://mvnrepository.com/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[WARNING] The POM for org.apache.maven.plugins:maven-clean-plugin:jar:2.5 is missing, no dependency information available
Downloading from mirrorId: http://mvnrepository.com/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.jar
·
·太长了,省略一部分。。。
·
[WARNING] Failed to retrieve plugin descriptor for org.apache.maven.plugins:maven-release-plugin:2.5.3: Plugin org.apache.maven.plugins:maven-release-plugin:2.5.3 or one of its dependencies could not be resolved: Could not find artifact org.apache.maven.plugins:maven-release-plugin:jar:2.5.3 in mirrorId (http://mvnrepository.com/)
Downloading from mirrorId: http://mvnrepository.com/org/apache/maven/plugins/maven-metadata.xml
Downloading from mirrorId: http://mvnrepository.com/org/codehaus/mojo/maven-metadata.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.293 s
[INFO] Finished at: 2018-07-17T18:28:05+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'help' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:\.m2\repository), mirrorId (http://mvnrepository.com/)] -> [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] 

解决过程

使用mvn -X -e help:system 获取详细日志,发现有提示找不到maven-metadata.xml,在仓库中搜索后发现有的是maven-metadata-alimaven.xml。
于是想到是不是与settings.xml中的mirrors配置有关,于是增加如下配置:

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

此处的id配置与maven-metadata-alimaven.xml中的alimaven部分保持一致。

然后重新运行mvn help:system,问题得到了解决。

总结

机器B中的远程仓库,来源于aliyun仓库,所以本地的metadata文件也与之相关,在机器A中如果不配置则会找默认的文件,找不到就导致了需要重新下载相关的内容。

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值