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’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
The org.jvnet.localizer
is only available at Java.net repository.
<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.
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 a remote repository
in your pom.xml
file like this :
<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.
You can also download the jar files with dependencies from this site: http://jar-download.com/
i’m start learning about maven, and your blog is very helpful. thank you verymuch.
Your blog is very helpful for beginners in maven. I wanted to know, how do I find out the of a repository when I already have the dependency information. for example, the dependency information is:
org.eclipse.equinox
org.eclipse.osgi
3.4.2
how do I find out the repository information from the element
Try this – http://search.maven.org/
In the post you have mentioned “…a dependency that is not present in the local repository (or for a SNAPSHOT, when the remote repository contains one that is newer)… “. I don’t know what you mean by the term “SNAPSHOT”. Can you please explain it a bit or direct me to the link where it is explained.
Thanks.
?????????snapshot??????????
A snapshot version in Maven is one that has not been released.
The idea is that before a 1.0 release (or any other release) is done, there exists a 1.0-SNAPSHOT. That version is what might become 1.0. It’s basically “1.0 under development”. This might be close to a real 1.0 release, or pretty far (right after the 0.9 release, for example).
The difference between a “real” version and a snapshot version is that snapshots might get updates. That means that downloading 1.0-SNAPSHOT today might give a different file than downloading it yesterday or tomorrow.
Usually, snapshot dependencies should only exist during development and no released version (i.e. no non-snapshot) should have a dependency on a snapshot version.
Greate mkyong…
Very Very thanks to u for ur Tutorial……………
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
it depends on the process.
usual water fall way .
requirement Specification -> Architechture-> ->functional specifications -> design -> implmentation (development ) -> unit testing -> QA testing -> system integration testing -> UAT deployment -> UAT testing (user acceptance testing ) -> production deployment -> post production support
correct me If I am wrong