java - Maven 无法下载 jar 依赖项

标签 java windows maven

我创建了一个非常简单的默认应用程序,用于在我的 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)

最佳答案

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

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

Known Limitation:

The main limitation is that you can't download data that doesn't fit entirely into memory.

所以我为 Maven 增加了内存:

导出 MAVEN_OPTS="-Xmx1024m"

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

关于java - Maven 无法下载 jar 依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7074040/

相关文章:

java - 无法找到或加载主类: Executable JAR from Maven

java - jtable 单元格渲染器在运行时更改单元格的背景颜色

java - 将两个整数附加到十六进制,每个整数代表一个半字节。数字

python - 为什么即使子进程已完成,Popen.poll() 也会返回 None 的返回码?

windows - "TCHAR cFileName[MAX_PATH];"- MSDN 库中的错误?

unit-testing - 使用 Maven,如何运行特定测试?

java - 如何在构建过程中在 jar 外部创建 configs 目录

java - 多级字符串分割

java - 在 Android 中打开 Fragment 时使完整背景变暗

c++ - fatal error : google/protobuf/port_def. inc : No such file or directory #include <google/protobuf/port_def. inc>