How do I use a mirror of the maven central repository?
Author: Deron Eriksson
Description: This tutorial describes how to use a mirror of the maven central repository.
Tutorial created using: Windows Vista || JDK 1.6.0_04 || Eclipse Web Tools Platform 2.0.1 (Eclipse 3.3.1)


Page:    1 2 >

Currently, the mavenSW central repository is located at http://repo1.maven.org/maven2. You can find this URL specified in the super pom.xml file in maven-2.0.8-uber.jar at org/apache/maven/project/pom-4.0.0.xml.

Sometimes, it can be useful to utilize a public mirror of the central repository. For instance, on the rare occasion that the central repository is down, you could specify to use a mirror of the repository rather than the central repository. Also, if there is a mirror that is geographically close to you, there could be a time savings in utilizing a public mirror. A list of several mirrors exists at http://maven.apache.org/guides/mini/guide-mirror-settings.html.

If you work in a decent-sized company with several developers, you might want to create a mirror of the central repository for you intranet, since in terms of performance and bandwidth use it makes sense to have your developers utilize a central repository mirror within your company.

You can use a mirror of the central repository by specifying a mirror element in your settings.xml file. If you specify "central" for the mirrorOf element, this means that this is a mirror of the central maven repository, and this server will be utilized rather than the default central repository. I added the following mirror element to my settings.xml file to specify that I want to use a mirror of the central repository in Denmark.

mirror entry from settings.xml

...
    <mirror>
      <id>dotsrc.org</id>
      <url>http://mirrors.dotsrc.org/maven2</url>
      <mirrorOf>central</mirrorOf>
      <!-- Denmark -->
    </mirror>
...

Now that I've updated my settings.xml file, I'll run a "mvn install" command on my "mytest" project, which requires the "maven-install-plugin-2.2.jar" file. (Note: Maven had previously downloaded this jarW file, so for this example I deleted it out of my local maven repository so that maven would download it again).

Execute 'mvn install' on 'mytest' project

(Continued on page 2)

Page:    1 2 >