Home Ask Login Register

Developers Planet

Your answer is one click away!

Oscar February 2016

maven repository setting.xml the mirrorof

    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
      <name>Human Readable Name for this Mirror.</name>
        <name>Nexus osc</name>
        <name>Nexus osc thirdparty</name>

What is the exactly using of mirrorOf? Will maven first try get jar from id=nexus-osc and then nexus-osc-thirdparty and then maven2? I have already checked the maven mirror setting guide but I still can not understand.


Tunaki February 2016

Quoting the Maven documentation about mirrors:

To configure a mirror of a given repository, you provide it in your settings file (${user.home}/.m2/settings.xml), giving the new repository its own id and url, and specify the mirrorOf setting that is the ID of the repository you are using a mirror of.

What this means is that mirrorOf points to an existing repository declaration and configures Maven to use that mirror when it attempts to connect the the specified repository.

Let's take an example. You have a project with the following repository defined in your project:


with the following declaration in your settings:

      <name>UK Central</name>

What this means is that whenever Maven will attempt to download a library from the my-internal-site repository, it will actually not use http://myserver/repo but, instead, use the mirror declaration and download the library from http://uk.maven.org/maven2.

It does not define any order. It just declares where Maven needs to download artifacts in place of the mirrored repository.

Specifying <mirrorOf>central

Post Status

Asked in February 2016
Viewed 3,905 times
Voted 9
Answered 1 times


Leave an answer

Quote of the day: live life