For maven to download the required artifacts of the build and dependencies (jar files) and other plugins which are configured as part of any project, there should be a common place where all such artifacts are placed. This common shared area is called as Repository in maven.
In maven, repositories are classified into 3 main categories as shown below :
The repository which resides in our local machine which are cached from the remote/central repository downloads and ready for the usage. The folder to hold/place all the dependencies in local can be configured in the settings.xml file of the maven folder under the tag
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <localRepository>D:/m2repo</localRepository> </settings>
This repository as the name suggests resides in the remote server and which can be accessed by using different file transfer protocols like
http://. Remote repository will be used for both downloading and uploading the dependencies and artifacts.
<repositories> <repository> <id>remote.repository</id> <url>http://download.ogrname.com/maven2/</url> </repository> </repositories>
This is the repository provided by maven community. This repository contains large set of commonly used/required libraries for any java project. Basically, internet connection is required if developers want to make use of this central repository. But, no configuration is required for accessing this central repository.
<repositories> <repository> <id>central.repository</id> <url>http://repo1.maven.org/maven2/</url> </repository> </repositories>
In the picture below you can see the organization of local and remote/central repositories.
Basically, when maven starts executing the build commands, maven starts for searching the dependencies as explained below :