eclipse Maven 不会自动下载依赖

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11822400/
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 18:46:11  来源:igfitidea点击:

Maven does not automatically download dependencies

eclipsemavenm2eclipse

提问by u1516331

I'm a starter for Maven. I pulled a java maven project from Bitbucket. When compiling the prject Eclipse said "8/6/12 1:39:05 PM EST: Missing artifact com.tinkerpop.blueprints:blueprints-core:jar:1.0:compile":

我是 Maven 的初学者。我从 Bitbucket 中提取了一个 java maven 项目。编译项目时 Eclipse 说“8/6/12 1:39:05 PM EST: Missing artifact com.tinkerpop.blueprints:blueprints-core:jar:1.0:compile”:

Maven console:

Maven控制台:

8/6/12 1:39:03 PM EST: Missing artifact com.tinkerpop.blueprints:blueprints-core:jar:1.0:compile
8/6/12 1:39:05 PM EST: Missing artifact com.tinkerpop.blueprints:blueprints-core:jar:1.0:compile

but when I check the pom.xml file, it is already there in the dependency list, only the Type and Scope fields are empty. Seeing the errors, I try to add this dependency by myself. And it showed like this: enter image description hereThe #1 question is, Why for 1.0 version, blueprints-core only have a .pom file not a .jar file? Does this mean in the remote repository they don't provide the 1.0 version any more? (I found the codes in the project reply on 1.0 version instead of 2.0 version of this Blueprint framework)

但是当我检查 pom.xml 文件时,它已经存在于依赖项列表中,只有 Type 和 Scope 字段为空。看到错误,我尝试自己添加这个依赖项。它显示如下: 在此处输入图片说明#1 问题是,为什么对于 1.0 版本,blueprints-core 只有 .pom 文件而不是 .jar 文件?这是否意味着在远程存储库中他们不再提供 1.0 版本?(我在项目回复中找到了这个蓝图框架的1.0版本而不是2.0版本的代码)

The #2 questions is, under what circumstances Maven will not automatically download the jar files for the dependencies added?

#2 问题是,Maven 在什么情况下不会自动下载添加的依赖项的 jar 文件?

This is the original pom.xml file:

这是原始的 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">
    <parent>
        <groupId>edu.qut.cs</groupId>
        <artifactId>qut-recommender</artifactId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>../qut-recommender/pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <artifactId>rcmd-common</artifactId>
    <packaging>jar</packaging>
    <name>QUT Recommender Common Library and Utilty</name>

    <dependencies>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>11.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.mongodb</groupId>
            <artifactId>mongo-java-driver</artifactId>
            <version>2.7.2</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.mahout</groupId>
            <artifactId>mahout-ext</artifactId>
            <version>1.0-SNAPSHOT</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>jgrapht</groupId>
            <artifactId>jgrapht</artifactId>
            <version>0.7.3</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>com.tinkerpop.blueprints</groupId>
            <artifactId>blueprints-core</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
        </dependency>   
    </dependencies>

</project>

The POM and Jar files of 1.0 version exist. The following picture is the directories and files in the folder of "C:\Users\n8275441.m2\repository\com\tinkerpop\blueprints". BTW, I pulled this project from Bitbucket repository. Is it possible that those 1.0 version files came along with the project in Bitbuckdet? enter image description here

1.0 版本的 POM 和 Jar 文件存在。下图是“C:\Users\n8275441.m2\repository\com\tinkerpop\blueprints”文件夹下的目录和文件。顺便说一句,我从 Bitbucket 存储库中提取了这个项目。那些 1.0 版本的文件是否可能与 Bitbuckdet 中的项目一起出现? 在此处输入图片说明

回答by khmarbaise

Based on your information and after checking maven central the problem is based on the version you have selected. Maven Central contains only a version 1.2, 2.0.0 and 2.1.0 but not a version 1.0. Furthermore if a dependency is given without scope like in your pom:

根据您的信息并在检查 maven central 后,问题基于您选择的版本。Maven Central 仅包含版本 1.2、2.0.0 和 2.1.0 但不包含版本 1.0。此外,如果在您的 pom 中没有范围地给出依赖项:

<dependency>
  <groupId>com.tinkerpop.blueprints</groupId>
  <artifactId>blueprints-core</artifactId>
  <version>1.0</version>
</dependency>

this means default scope which is "compile" (as in the sense of convention over configuration). I would simply suggest to change the version to 2.0.0 or 2.1.0 which should solve the problem. If you check compiling such project i would suggest to do the first try on command line and not in Eclipse.

这意味着默认范围是“编译”(就像在配置上的约定一样)。我只是建议将版本更改为 2.0.0 或 2.1.0,这应该可以解决问题。如果您检查编译此类项目,我建议您在命令行上而不是在 Eclipse 中进行第一次尝试。

回答by Aaron Digulla

If you're wondering what Maven Central offers, mvnrepository.comis your friend.

如果您想知道 Maven Central 提供什么,mvnrepository.com是您的朋友。

In this case, there is no 1.0 version: http://mvnrepository.com/artifact/com.tinkerpop.blueprints/blueprints-core

在这种情况下,没有 1.0 版本:http: //mvnrepository.com/artifact/com.tinkerpop.blueprints/blueprints-core

Which leads to the interesting question why m2e reports a POM file for it. I suggest to have a look on your hard disk if the POM file really exists. You can find it (or not) in C:\Users\n8275441\.m2\repository\com\tinkerpop\blueprints\1.0\blueprints-core\

这引出了一个有趣的问题,为什么 m2e 会为其报告 POM 文件。如果 POM 文件确实存在,我建议查看您的硬盘。你可以在C:\Users\n8275441\.m2\repository\com\tinkerpop\blueprints\1.0\blueprints-core\

As for question #2: Maven (and m2e as well), will try to download a release (i.e. something that doesn't have SNAPSHOTin the version) only once. If the download fails, Maven will note that and never try again since it assumes that the upstream repositories (Maven Central, for example) heed the Maven rules (so if a repo doesn't have something, it won't have it tomorrow).

至于问题#2:Maven(以及m2e),只会尝试下载一个版本(即SNAPSHOT版本中没有的东西)一次。如果下载失败,Maven 会注意到这一点并且永远不会再试,因为它假设上游存储库(例如 Maven Central)遵循 Maven 规则(所以如果一个存储库没有东西,它明天就没有) .

For snapshots, Maven will try to download them once per day to get a good balance between keeping you up to date and not wasting your time waiting for some download.

对于快照,Maven 将尝试每天下载一次,以在让您保持最新状态和不浪费时间等待下载之间取得良好的平衡。