在Eclipse(Kepler)中创建MAVEN项目时出现错误。

3
我正在尝试在Eclipse中创建一个简单的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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.students.app</groupId>
  <artifactId>students-application</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <version>2.5</version>
        </plugin>
    </plugins>
  </build>
</project>

这是我的pom.xml文件,我遇到了以下错误:
Multiple annotations found at this line:
    - Failure to transfer org.apache.maven.plugins:maven-resources-
     plugin:pom:2.5 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-resources-
     plugin:pom:2.5 from/to central (http://repo.maven.apache.org/maven2): 
     Connection refused: no further information to http://
     repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-
     resources-plugin/2.5/maven-resources-plugin-2.5.pom
    - Plugin execution not covered by lifecycle configuration: 
     org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile 
     (execution: default-compile, phase: compile)
    - Plugin execution not covered by lifecycle configuration: 
     org.apache.maven.plugins:maven-compiler-plugin:2.3.2:testCompile 
     (execution: default-testCompile, phase: test-compile)
    - CoreException: Could not calculate build plan: Plugin 
     org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its 
     dependencies could not be resolved: Failed to read artifact descriptor for 
     org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2: 
     ArtifactResolutionException: Failure to transfer 
     org.apache.maven.plugins:maven-compiler-plugin:pom:2.3.2 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-compiler-plugin:pom:2.3.2 from/to 
     central (http://repo.maven.apache.org/maven2): Connection refused: no 
     further information to http://repo.maven.apache.org/maven2/org/apache/
     maven/plugins/maven-compiler-plugin/2.3.2/maven-compiler-
     plugin-2.3.2.pom 

我该怎么办?

你使用的是Windows还是Linux操作系统? - Vishal
我正在使用Windows工作。 - ShraddhaJ
在将项目导入IDE之前,一定要始终验证您是否可以从命令行构建项目。这将从一开始就消除大部分问题。现在看起来您可能需要在~/.m2/settings.xml文件中配置代理。 - Steve C
1个回答

3

问题可能是一些 ".lastUpdated" 阻止了你的下载,你需要删除 ".lastUpdated" 并更新maven项目。

定位 {user}/.m2/repository 并删除所有 "*.lastUpdated" 文件,你可以通过在 %USERPROFILE%.m2 中搜索 *.lastUpdated 然后删除Eclipse报告为有问题的文件来完成。

或者

cd %userprofile%\.m2\repository
for /r %i in (*.lastUpdated) do del %i

完成后,请从Eclipse中更新您的Maven项目。

非常感谢。这真是帮了大忙。 - ShraddhaJ

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接