Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between repository and dependency in Maven?

How are they different? Or are they the same?

like image 889
Koray Tugay Avatar asked Feb 24 '13 21:02

Koray Tugay


People also ask

What is repository and dependency?

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)

What is the repository of Maven?

A repository in Maven holds build artifacts and dependencies of varying types. There are exactly two types of repositories: local and remote: the local repository is a directory on the computer where Maven runs. It caches remote downloads and contains temporary build artifacts that you have not yet released.

What are the two types of Maven repositories?

There are 3 types of maven repository: Local Repository. Central Repository. Remote Repository.

Why do we use Maven repository?

Maven local repository keeps your project's all dependencies (library jars, plugin jars etc.). When you run a Maven build, then Maven automatically downloads all the dependency jars into the local repository. It helps to avoid references to dependencies stored on remote machine every time a project is build.


2 Answers

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

like image 185
gerrytan Avatar answered Oct 16 '22 08:10

gerrytan


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

like image 37
Stephanie Peters Avatar answered Oct 16 '22 10:10

Stephanie Peters