指定用于解决依赖关系的Maven存储库URL? [英] Specifying the maven repository URL for getting the dependencies resolved?

查看:339
本文介绍了指定用于解决依赖关系的Maven存储库URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解maven如何从存储库中下载二进制文件.

I am trying to understand how maven downloads the binaries from the repositories.

例如,我的项目具有以下依赖性:

For example, I have the following dependency for my project:

<dependency>
    <groupId>org.apache.hadoop</groupId>
    <artifactId>hadoop-hdfs</artifactId>
    <version>2.7.1</version>
</dependency>

现在,这些二进制文件位于 http://mvnrepository.com/中.

Now, these binaries are present in http://mvnrepository.com/.

在pom.xml中,我们有一个<repositories>标记,用于指定maven可以从其中下载文件的存储库URL,模板:

In pom.xml, we have <repositories> tag where we specify the repository URL from where maven can download the files, template:

<repositories>
    <repository>
        <id>mvnrepository_id</id>
        <name>mvnrepository.com</name>
        <url></url>
    </repository>

现在,我的疑问是,<url>的值应该是多少?是否必须是base url,例如 http://mvnrepository.com/或完整的URL? > http://mvnrepository.com/artifact/org.apache.hadoop/hadoop -hdfs

Now, my doubt is, what should be the value of the <url>; does it need to be the base url , like http://mvnrepository.com/ or the complete URL --> http://mvnrepository.com/artifact/org.apache.hadoop/hadoop-hdfs

在我看来,应该是每个依赖项的基本URL,否则我们必须输入完整的URL.

To me it appears that is should be the base url else for each dependency we have to put the complete URL.

有人可以帮我理解吗?

推荐答案

除非您要从不同于默认Central Maven存储库的存储库中获取工件,否则无需将<repositories>部分添加到您的pom.xml中.在此处

Unless you want to fetch artifacts from a repository different from the default Central Maven repository, you need not add the <repositories> section to your pom.xml. Read about Maven Repositories here and here.

,默认的Central Maven存储库的url http://repo.maven.apache. org/maven2/.

And the url for default Central Maven repository is http://repo.maven.apache.org/maven2/.

PS::您发布的URL是网站的URL.

PS: The URLs you have posted are the ones for the Website.

这篇关于指定用于解决依赖关系的Maven存储库URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆