Maven 无法下载 jar 依赖项

2022-09-01 03:53:38

我有一个非常简单的默认应用程序,我创建了一个应用程序,用于在我的Windows 7计算机上测试我的Eclipse Indigo / Maven v3.0.1设置。Hello World应用程序从Eclipse运行良好。

现在,从命令行中,我正在尝试使用 进行测试。mvn install

在这一点上,我看到Maven下载了一大系列的依赖项。由于某种原因,虽然它会卡住下载一个,并且会中途停止。它不是每次都在同一点,但它目前始终是相同的jar文件,例如......

http://repo1.maven.org/maven2/org/apache/maven/surefire/surefire-booter/2.5/surefire-booter-2.5.jar

如果我从浏览器下载此文件,它可以完美地工作。事实上,相当快。现在,如果我手动将下载的文件复制到存储库目录中的相应目录,则安装将继续下载依赖项,直到它随机命中另一个依赖项,然后停止。.m2

这是我的POM,尽管我不确定它是否会有所帮助,因为它是如此基本,并且似乎可以很好地与.mvn compile

<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.kyeema</groupId>
  <artifactId>QServer</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>QServer</name>
  <url>http://maven.apache.org</url>

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

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

以下是一些引用一些虚拟jar文件的调试输出?

[INFO] Surefire report directory: C:\workspace\QServer\target\surefire-reports
[DEBUG] Setting system property [user.dir]=[C:\workspace\QServer]
[DEBUG] Setting system property [localRepository]=[C:\Users\Andre\.m2\repository]
[DEBUG] Setting system property [basedir]=[C:\workspace\QServer]
[DEBUG] Using JVM: C:\Program Files\Java\jdk1.7.0\jre\bin\java
[DEBUG] dummy:dummy:jar:1.0 (selected for null)
[DEBUG]   org.apache.maven.surefire:surefire-booter:jar:2.7.2:compile (selected for compile)
[DEBUG]     org.apache.maven.surefire:surefire-api:jar:2.7.2:compile (selected for compile)
[DEBUG] Adding to surefire booter test classpath: C:\Users\Andre\.m2\repository\org\apache\maven\surefire\surefire-booter\2.7.2\surefire-booter-2.7.2.jar Scope: compile
[DEBUG] Adding to surefire booter test classpath: C:\Users\Andre\.m2\repository\org\apache\maven\surefire\surefire-api\2.7.2\surefire-api-2.7.2.jar Scope: compile
[DEBUG] dummy:dummy:jar:1.0 (selected for null)
[WARNING] Missing POM for org.apache.maven.surefire:surefire-junit3:jar:2.7.2: Error resolving project artifact: Failure to find org.apache.maven.surefire:surefire-junit3:pom:2.7.2 in http://mirrors.ibiblio.org/pub/mirrors/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of ibiblio.org has elapsed or updates are forced for project org.apache.maven.surefire:surefire-junit3:pom:2.7.2
[DEBUG]   org.apache.maven.surefire:surefire-junit3:jar:2.7.2:test (selected for test)
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.626s
[INFO] Finished at: Tue Aug 16 13:18:42 PDT 2011
[INFO] Final Memory: 8M/154M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.7.2:test (default-test) on project QServer: Error to resolving surefire provider dependency: Missing:
[ERROR] ----------
[ERROR] 1) org.apache.maven.surefire:surefire-junit3:jar:2.7.2
[ERROR] 
[ERROR] Try downloading the file manually from the project website.
[ERROR] 
[ERROR] Then, install it using the command:
[ERROR] mvn install:install-file -DgroupId=org.apache.maven.surefire -DartifactId=surefire-junit3 -Dversion=2.7.2 -Dpackaging=jar -Dfile=/path/to/file
[ERROR] 
[ERROR] Alternatively, if you host your own repository you can deploy the file there:
[ERROR] mvn deploy:deploy-file -DgroupId=org.apache.maven.surefire -DartifactId=surefire-junit3 -Dversion=2.7.2 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]
[ERROR] 
[ERROR] Path to dependency:
[ERROR] 1) dummy:dummy:jar:1.0
[ERROR] 2) org.apache.maven.surefire:surefire-junit3:jar:2.7.2
[ERROR] 
[ERROR] ----------
[ERROR] 1 required artifact is missing.
[ERROR] 
[ERROR] for artifact:
[ERROR] dummy:dummy:jar:1.0
[ERROR] 
[ERROR] from the specified remote repositories:
[ERROR] ibiblio.org (http://mirrors.ibiblio.org/pub/mirrors/maven2, releases=true, snapshots=false)

答案 1

好吧,伙计们,我在下载大文件时遇到了同样的问题。我们可能都在使用轻量级的HTTP旅行车。如果您查看文档:

http://maven.apache.org/wagon/wagon-providers/wagon-http-lightweight/

已知限制:

主要限制是您无法下载不完全适合内存的数据。

所以我增加了Maven的内存:

export MAVEN_OPTS="-Xmx1024m"

瞧,它有效。(!!!!)


答案 2

我遇到了同样的问题。在我的情况下,AVG防病毒软件阻止了Maven下载工件。暂时禁用它会有所帮助。


推荐