Dependencies and Repositories?

随声附和 提交于 2019-12-11 06:15:10

问题


I am new to Maven and I previously saw another question regarding the similar thing but I am still confused.

What is the difference between dependencies and repository in relation to libraries?
I am aware that dependencies contain libraries that the project can be referred to. But how would it relate to external dependencies?


回答1:


When you use maven there is a chain of repostitories. Each repository containers a store of library code, uniquely identified by group/artifact/version (GAV).

1) At the top level is maven central on the internet.

2) At the next level their is usally a corporate repository, Nexus or JFrog or similar.

3) On your local machine their is a repository, usually under your home directory .m2/repo

When you include a dependency in a pom like :

<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-io</artifactId>
    <version>1.3.2</version>
</dependency>

and then do a maven build it will go up the tree looking first in your local repo, then in your corporate, then finally in maven-central. Each time it runs it will download the dependency to your local repo so it is ready next time.



来源:https://stackoverflow.com/questions/43676192/dependencies-and-repositories

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