Specifying the maven repository URL for getting the dependencies resolved?

天大地大妈咪最大 提交于 2020-07-16 07:11:51

问题


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>

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

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>

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

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

Can anyone help me understand this?


回答1:


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.

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

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



来源:https://stackoverflow.com/questions/43342762/specifying-the-maven-repository-url-for-getting-the-dependencies-resolved

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!