How to download from Maven remote repository?
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 need some libraries that are NOT EXITS the Maven center repository, the process will stopped and output error messages to your Maven console.
Example
The org.jvnet.localizer library is not available at Maven central repository, but Maven remote repository, which is http://download.java.net/maven/2/.
<dependency> <groupId>org.jvnet.localizer</groupId> <artifactId>localizer</artifactId> <version>1.8</version> </dependency>
To tell Maven to go to Maven remote repository like java.net, you need to declared a “remote repository” in your Maven’s pom.xml file like this :
<repositories> <repository> <id>java.net</id> <url>http://download.java.net/maven/2</url> </repository> </repositories>
Now, Maven’s dependency libraries look-up sequences is changed to :
- Search in Maven local repository, if not found, continue step 2, else exit.
- Search in Maven central repository, if not found, continue step 3, else exit.
- Search in java.net Maven remote repository – , if not found, prompt error message, else exit.
hello mkyong,
I learnt a few java technologies before. now am learning new technologies from yours.
since am a novice to real tome development, am just curious to know how the project phases go on from specification to testing.
could you post an article or ideas accordingly. Thank you
[...] Maven remote repository – link1, link2 Not all libraries are store in Maven central repository, often times, you need to add some remote repositories to download the libraries from another location instead of the default central repository. [...]