pom.xml Maven构建中出错

时间:2014-02-12 07:28:41

标签: eclipse maven m2eclipse

我在尝试构建maven项目时在我的pom.xml中收到错误。这个插件出现错误:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>

这是Eclipse显示的错误:

Multiple annotations found at this line:
- Plugin execution not covered by lifecycle configuration: org.apache.maven.plugins:maven-compiler-plugin:
 2.3.2:compile (execution: default-compile, phase: compile)
- CoreException: Could not get the value for parameter compilerId for plugin execution default-compile: 
 PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:2.3.2 or one of its dependencies could not 
 be resolved: Failed to collect dependencies for org.apache.maven.plugins:maven-compiler-plugin:jar:2.3.2 (): 
 ArtifactDescriptorException: Failed to read artifact descriptor for org.apache.maven:maven-toolchain:jar:1.0: 
 ArtifactResolutionException: Failure to transfer org.apache.maven:maven-toolchain:pom:1.0 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:maven-toolchain:pom:1.0 from/to central (http://
 repo.maven.apache.org/maven2): The operation was cancelled.

5 个答案:

答案 0 :(得分:9)

似乎解决方案失败了。

使用-U标志运行mvn以忽略缓存并重新尝试解析

(alt + f5对话框也可能有帮助)

答案 1 :(得分:7)

当我遇到这个问题时,我发现这是由于之前的网络问题。本地Maven存储库避免立即重新尝试。解决此问题的最佳方法是使用eclipse“更新Maven项目”(ALT + F5)功能结束检查“强制更新快照/版本”选项。

答案 2 :(得分:0)

这对我不起作用,将maven编译器版本更改为2.5.1终于为我工作了,希望这可以帮助那些仍在努力解决这种依赖性的人

<build>
     <pluginManagement>
        <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.5.1</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
        </plugins>
        </pluginManagement>
    </build>

答案 3 :(得分:0)

按(ALT + F5)更新Maven项目,然后选择“强制更新快照/版本”选项。也适合我

答案 4 :(得分:0)

有类似的问题。 Maven更新和强制更新快照对我不起作用。

已按照以下步骤操作,问题已解决:

  1. 在eclipse中删除项目。
  2. 删除.Project文件和。设置文件夹。
  3. 再次将项目导入为现有的maven项目。