When
you build a Maven’s project, Maven will check your
This is how the Maven central repository website looks like
According to Apache Maven :
pom.xml
Updated 12/12/2012
The
pom.xml
pom.xml
file,
to identify which dependency to download. First, Maven will get the
dependency from your local repository Maven
local repository,
if not found, then get it from the default Maven
central repository
– http://repo1.maven.org/maven2/This is how the Maven central repository website looks like
According to Apache Maven :
Downloading in Maven is triggered by a project declaring a dependency that is not present in the local repository (or for a SNAPSHOT, when the remote repository contains one that is newer). By default, Maven will download from the central repository.In Maven, when you’re declared library does not exist either inlocal repository nor Maven center repository, the process will stop and output error messages to your Maven console.
1. Example
Theorg.jvnet.localizer
is only available at Java.net
repository.pom.xml
<dependency> <groupId>org.jvnet.localizer</groupId> <artifactId>localizer</artifactId> <version>1.8</version> </dependency>When you build this Maven project, it will fail and output dependency not found error message.
Updated 12/12/2012
The
org.jvnet.localizer
is now available in Maven center repository.2. Declare Java.net repository
To tell Maven to get the dependency from Java.net, you need to declared aremote
repository
in your
pom.xml
file like this :pom.xml
<repositories> <repository> <id>java.net</id> <url>https://maven.java.net/content/repositories/public/</url> </repository> </repositories>Now, Maven’s dependency library look-up sequences is changed to :
- Search in Maven local repository, if not found, go step 2, else exit.
- Search in Maven central repository, if not found, go step 3, else exit.
- Search in java.net Maven
remote repository, if not found, prompt error message, else exit.
Maven’s
dependency mechanism help to download all the necessary dependency
libraries automatically, and maintain the version upgrade as well.