Adding different mirrors for maven / Mirror management in Apache maven

In some cases it may takes a lot of time during a maven build as it is necessary to download required dependecies from the maven central repo. Maven uses a mirror, located in California, United States for downlowding required maven dependencies during a maven bulid. Even there has been implemented a balance loader for the default maven mirror (http://repo1.maven.org) recently it might make sense to overwrite the default behavior and set the mirror manually cause of: -) A mirror is geographically closer and faster -) Use an internal mirror (e.g. repo - proxy) Maven allows different settings to improve speed and make the downloading process more efficient and fast. Depending on the workflow two different soultions can be an adequate approach for the problem, described above.
1 answer

Adding a new maven mirror and overwrite the default behavior

At the user's home directory (e.g. C:\Users\\ on a Windows machine, or /Users/ on a Mac) there is a hidden directory, called .m2. Within this directory there is a settings.xml file. It may be that this file is not existing, than just create a new text file and save it as settings.xml

Withing the XML file, the following notation allows to manually specify a mirror: see attached image.

The reference of the xml elements is:
mirrorOf: The server ID of the repository being mirrored (e.g "central")
name: A name of the mirror (optional, just for documentation purpose)
url: The url of the mirror
id: A freely selectable id of the mirror entry

Please check the attached file for an example.

Taggings: