问题
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