Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from/to central


問題:

maven安裝完成,環境變量配置沒有問題,cmd窗口運行mvn compile的時候報錯如下:

Plugin org.apache.maven.plugins:maven-resources-plugin:2.6 or one of its dependencies could not be resolved: 
Failed to read artifact descriptor for org.apache.maven.plugins:maven-resources-plugin:jar:2.6: 
Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from/to central (https://repo.maven.apache.org/maven2): Connect to repo.maven.apache.org:443 [repo.maven.apache.org/151.101.52.215] failed: Connection timed out: connect -> [Help 1]

 

解決方案:

1. 經紅色字體可以得知,不能在https://repo.maven.apache.org/maven2這個網址下載到maven-resources-plugin:jar:2.6jar包,於是我瀏覽器訪問了紅色網址,可以訪問的到。

2. 我把從其他地方得到的2.6的maven-resources-plugin jar包和pom相關文件放到maven指定的目錄下,可是錯誤依舊,嘗試失敗。

3. 從網上搜到這種問題的解決方案之一:是在pom.xml中加入依賴如下,有些人用這個方法解決了問題,但是我的問題依舊。

<dependency>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-resources-plugin</artifactId>
  <version>2.6</version>
</dependency>

4. 開始放大招了,最后搜索到一種方法,直接把maven安裝文件夾的conf文件夾下的 settings.xml文件配置如下:

<mirrors>

    <!-- maven官方鏡像 -->
    <mirror>
    <id>mirrorId</id>
    <mirrorOf>central</mirrorOf>
    <name>Human Readable Name </name>
    <url>http://repo1.maven.org/maven2/</url>
    </mirror>

 
    <!-- 阿里雲鏡像1 -->
    <mirror> 
	<id>alimaven</id> 
	<name>aliyun maven</name> 
	<url>http://central.maven.org/maven2</url> 
	<mirrorOf>central</mirrorOf> 
    </mirror>
    <!-- 阿里雲鏡像2 -->
    <mirror> 
	<id>alimaven</id>
	<name>aliyun maven</name>
	<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
	<mirrorOf>central</mirrorOf>
    </mirror>

</mirrors>

  最后問題得以解決。這種問題出現的原因就是,聯通的網段,無法訪問maven.org網站。

 

  最后感謝博主提供了答案:https://www.cnblogs.com/1446358788-qq/articles/9597877.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM