簡體   English   中英

eclipse (pom.xml) 中的 Maven 錯誤:無法傳輸 org.apache.maven.plugins:maven-surefire-plugin:pom:2.12.4

[英]Maven error in eclipse (pom.xml) : Failure to transfer org.apache.maven.plugins:maven-surefire-plugin:pom:2.12.4

我想使用 Maven 制作 web 項目來自動導入我需要的所有庫,所以我選擇了"maven-archetype-webpp"

之后,我在 pom.xml 文件上收到此錯誤:

Description Resource Path Location Type Failure to transfer org.apache.maven.plugins:maven-surefire-plugin:pom:2.12.4 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven.plugins:maven-surefire-plugin:pom:2.12.4 from/to central (http://repo.maven.apache.org/maven2): The operation was cancelled. pom.xml /SpringTuto line 1 Maven Configuration Problem

我已經更新了我的 Maven 項目,但沒有結果!!

POM.XML :

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.pre.example</groupId>
  <artifactId>SpringTuto</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>SpringTuto Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>SpringTuto</finalName>
  </build>
</project>

您只需按照以下步驟操作:

  1. 右鍵單擊您的項目:Run (As) -> Maven clean
  2. 右鍵單擊您的項目:Run (As) -> Maven install

之后,如果在執行 Maven Install 時構建失敗,則表示 WEB-INF 下沒有 web.xml 文件或與之相關的一些問題。 真的行

右鍵單擊項目-> Maven-> 單擊復選框“強制更新”-> 更新

只需右鍵單擊您的項目,將 Maven 懸停然后單擊更新項目..完成!!

在我的情況下,導入 eclipse 失敗。 我不得不從 Eclipse 中刪除該項目(當然不刪除文件系統)並重新導入它。 之后,錯誤立即消失了。

如果您使用的是 Eclipse Neon,請嘗試以下操作:

1)在POM的屬性部分添加maven插件:

<properties>
    <java.version>1.8</java.version>
    <maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
</properties>

2)通過右鍵單擊項目強制更新項目快照

Maven -> 更新項目 -> 選擇你的項目 -> 勾選“強制更新快照/發布”選項 -> 確定

右鍵單擊您的項目:Run (As) -> Maven clean 右鍵單擊​​您的項目:Run (As) -> Maven install

對於 Unix 用戶

find ~/.m2 -name "*.lastUpdated" -exec grep -q "Could not transfer" {} \\; -print -exec rm {} \\;

右鍵單擊您的項目並選擇更新依賴項

對於 Windows

  • CD(更改目錄)到 .m2\\repository
  • for /r %i in (*.lastUpdated) do del %i執行for /r %i in (*.lastUpdated) do del %i的命令
  • 然后右鍵單擊您的項目並選擇更新依賴項

就我而言,eclipse 使用的是舊的 settings.xml 文件。

對於這個問題,我有一個更簡單的解決方案,它對我很有用。

只需選擇您的項目

右鍵單擊並選擇Properties

在左側邊欄列表中選擇Java Build Path

Order 和 Export選項卡中檢查 (1) JRE System Library [your java Version] 和 (2) Maven Dependencies (最初未選中)。

然后單擊應用並關閉按鈕。

只需更新您的項目(點擊應用和關閉時自動更新),錯誤就消失了。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM