What is the difference between repository and dependency in Maven?

淺唱寂寞╮ 提交于 2019-12-08 15:50:21

问题


How are they different? Or are they the same?


回答1:


Repository is a collection of artifacts (eg: jars). You can think of it as a mere storage / cache of various artifacts.

Dependency is a situation where your project dependent on another artifact to perform its task (eg: compile, run, unit test)

On a maven project you typically declare what artifacts you need on the <dependency> section of your pom, and you can also declare what repositories maven should lookup the dependency from at the <repositories> section.

By default maven will lookup the artifacts on the central repository. But it's common for an organization to have an internal repository containing in-house developed artifacts. Hence typically <repositories> section on the pom is configured with this.

http://maven.apache.org/guides/index.html




回答2:


The repository is where your libraries (aka artifacts) are stored. Dependencies are the names of the libaries that your corrent project depends on



来源:https://stackoverflow.com/questions/15057138/what-is-the-difference-between-repository-and-dependency-in-maven

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