当前位置: 首页 > 面试题库 >

Maven无法下载jar依赖项

云韬
2023-03-14
问题内容

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

问题答案:

好吧,这是我所经历的答案。

如果我将Maven保留在v3.0.1,则必须添加上面列出的镜像,并且该镜像可以正常工作。

如果我将Maven升级到v3.0.3,则必须删除上面列出的镜像才能使其正常工作。:-)

我在两台不同的计算机上尝试了此方法,并且具有相同的行为。这可能意味着这里的网络应该归咎于它们都通过同一路由器。

无论如何,所以这里实际上有两个解决方法。我不确定这是否是“正确”的回答,但它们至少使我向前迈进了一步。

感谢所有提交的答案。



 类似资料:
  • 一个月前,我可以在IntelliJ的基础上从头开始成功地构建Java应用程序,现在,我必须升级spring boot以获得一些新功能。但是,在我将spring boot的版本从2.2.2更改之后。发布到其他版本,然后单击“重新加载所有Maven项目”按钮,我会收到以下消息: 一个月前下载2.2.2还可以。释放。为什么此时更新失败?我的信息如下:MacOS 12.2,捆绑(Maven 3),Java

  • 问题内容: 当我输入command go build时,我有一个项目具有来自bitbucket上私人存储库的多个依赖项。我得到这个错误 无法识别的导入路径“ bitbucket.xxx.xx / xx / x” x509:证书由未知授权机构签名 我已经尝试了几种方法,例如添加令牌 git config –global http.extraheader令牌 配置为ssh git config –gl

  • 当我试图构建我的项目时,我有以下错误:

  • 问题内容: 我需要将我们的maven build java项目发布给远程质量检查团队。为此,我想下载所有依赖项,并发送给他们,这样他们就不需要下载它们了。 当前,所有依赖项都在pom.xml文件中定义,并且我们使用mvn install或mvn包来构建项目。一些项目成员使用uber jars,其他一些项目则使用jars +依赖项来执行。 什么是最简单的方法来预打包相关的jar文件,以使从Inter

  • Maven依赖项处理(即下载)是否通过插件完成 Maven是否在秘密使用依赖插件(https://maven.apache.org/plugins/maven-dependency-plugin/)?

  • 如何将这个插件添加为依赖项和插件?我如何将此用作依赖项? 谢谢