eclipse eclipse中使用m2e插件的Maven项目依赖错误(对于maven)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13372359/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 19:24:02  来源:igfitidea点击:

Maven project dependency error in eclipse using m2e plugin (for maven)

javaeclipsemavenm2e

提问by suxumuxu

I am working on a java maven project in eclipse using the m2e plugin. I updated my system and my jvm updated from icedtea-bin-6.1.11.4 to icedtea-bin-6.1.11.5. Eclipse now outputs the below error in my pom file and I can't run my project. I am new to maven and eclipse and, after a day of googling, I still haven't managed to find a solution for this.

我正在使用 m2e 插件在 eclipse 中开发一个 java maven 项目。我更新了我的系统,我的 jvm 从 icedtea-bin-6.1.11.4 更新到了 icedtea-bin-6.1.11.5。Eclipse 现在在我的 pom 文件中输出以下错误,我无法运行我的项目。我是 maven 和 eclipse 的新手,经过一天的谷歌搜索,我仍然没有找到解决方案。

I personally think that this is some sort of problem with eclipse (a misconfiguration?), because I am able to get a successful build on the command line with mvn clean install -U. Moreover, I get the same error even on a fresh eclipse install without the plugins installed.

我个人认为这是 eclipse 的某种问题(配置错误?),因为我能够在命令行上使用mvn clean install -U. 此外,即使在没有安装插件的全新 eclipse 安装中,我也会遇到同样的错误。

Error:

错误:

Execution default-resources of goal org.apache.maven.plugins:maven-resources-plugin:2.5:resources failed: Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of its dependencies could not be resolved: Failure to transfer commons-cli:commons-cli:jar:1.0 from http://repo.maven.apache.org/maven2was 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 commons-cli:commons-cli:jar:1.0 from/to central (http://repo.maven.apache.org/maven2): connection timed out to http://repo.maven.apache.org/maven2/commons-cli/commons-cli/1.0/commons-cli-1.0.jar(org.apache.maven.plugins:maven-resources-plugin:2.5:resources:default-resources:process-resources)

目标 org.apache.maven.plugins:maven-resources-plugin:2.5:resources failed: Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 或其依赖项之一无法解析的执行默认资源: 无法从http://repo.maven.apache.org/maven2传输 commons-cli:commons-cli:jar:1.0已缓存在本地存储库中,直到 central 的更新间隔已过或才会重新尝试解析强制更新。原始错误:无法将工件 commons-cli:commons-cli:jar:1.0 from/to central (http://repo.maven.apache.org/maven2):连接超时到http://repo.maven。 apache.org/maven2/commons-cli/commons-cli/1.0/commons-cli-1.0.jar(org.apache.maven.plugins:maven-resources-plugin:2.5:resources:default-resources:process-resources)

Environment details.

环境细节。

Maven: Apache Maven 2.2.1 (r801777; 2009-08-06 20:16:01+0100) Java version: 1.6.0_24 Java home: /opt/icedtea-bin-6.1.11.5/jre

Maven:Apache Maven 2.2.1 (r801777; 2009-08-06 20:16:01+0100) Java 版本:1.6.0_24 Java 主页:/opt/icedtea-bin-6.1.11.5/jre

Eclipse: Version: Juno Service Release 1 Build id: 20121004-1855

Eclipse:版本:Juno Service Release 1 构建 ID:20121004-1855

Plugin: m2e - Maven Integration for Eclipse 1.2.0.20120903-1050 m2e - slf4j over logback logging (Optional) 1.2.0.20120903-1050

插件:m2e - Eclipse 的 Maven 集成 1.2.0.20120903-1050 m2e - slf4j over logback logging(可选)1.2.0.20120903-1050

pom.xml

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.test</groupId>
  <artifactId>mf</artifactId>
  <version>0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>mf</name>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>cc.mallet</groupId>
      <artifactId>mallet</artifactId>
      <version>2.0.7-RC2</version>
    </dependency>

    <dependency>
      <groupId>com.googlecode.efficient-java-matrix-library</groupId>
      <artifactId>ejml</artifactId>
      <version>0.20</version>
    </dependency>

    <dependency>
      <groupId>jfreechart</groupId>
      <artifactId>jfreechart</artifactId>
      <version>1.0.0</version>
    </dependency>
  </dependencies>

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

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>2.3.1</version>
        <configuration>
          <archive>
            <manifestEntries>
              <Main-Class>lda.TMRS</Main-Class>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>1.7</version>
        <executions>
          <execution>
            <id>shade</id>
            <goals>
              <goal>shade</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>

Does anybody have any suggestions on how to get rid of this error?

有人对如何摆脱此错误有任何建议吗?

采纳答案by Andrzej Jozwik

You have cached files in your local repository. See:
Failure to transfer commons-cli:commons-cli:jar:1.0 from http://repo.maven.apache.org/maven2 was cached in the local repository

您在本地存储库中缓存了文件。看:
Failure to transfer commons-cli:commons-cli:jar:1.0 from http://repo.maven.apache.org/maven2 was cached in the local repository

Try to remove either $M2_HOME/repositoryor only mentioned files from your $M2_HOME/repository:

尝试$M2_HOME/repository从您的$M2_HOME/repository以下文件中删除或仅删除提及的文件:

  • commons-cli/commons-cli*
  • 公地-cli/公地-cli*