Maven project dependency error in eclipse using m2

2019-05-07 06:01发布

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.

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.

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/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 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)

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

Eclipse: Version: Juno Service Release 1 Build 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

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?

1条回答
男人必须洒脱
2楼-- · 2019-05-07 07:06

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

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

  • commons-cli/commons-cli*
查看更多
登录 后发表回答