我想使用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>
答案 0 :(得分:65)
您只需按照以下步骤操作:
答案 1 :(得分:5)
右键点击项目 - &gt; Maven-&gt;单击复选框'强制更新' - >更新
答案 2 :(得分:2)
右键单击您的项目,悬停maven,然后单击更新项目..完成!!
答案 3 :(得分:2)
在我的情况下,这是对Eclipse的导入失败。 我不得不从eclipse中删除项目(当然没有删除文件系统)并重新导入它。之后,错误立即消失。
答案 4 :(得分:1)
如果您使用的是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->更新项目->选择您的项目->选中“强制更新快照/发布”选项->确定
答案 5 :(得分:0)
右键单击您的项目:运行(As)-> Maven clean 右键单击您的项目:运行(As)-> Maven安装
答案 6 :(得分:0)
对于Unix用户
查找〜/ .m2-名称“ * .lastUpdated” -exec grep -q“无法传输” {} \; -print -exec rm {} \;
右键单击您的项目,然后选择“更新依赖项”
对于Windows
for /r %i in (*.lastUpdated) do del %i
答案 7 :(得分:0)
在我的情况下,eclipse使用的是旧的settings.xml文件。