Reputation: 5850
I have two computers. One always downloads from http://repo1.maven.org. While another one downloads from http://repo.maven.apache.org.
Today, I got checksum error like this on the first computer.
[WARNING] Checksum validation failed, expected but is 63801e851fe885601a0bd0eceb6501f7db37e47e for http://repo1.maven.org/maven2/org/codehaus/plexus/plexus-archiver/1.0-alpha-6/plexus-archiver-1.0-alpha-6.pom
On the second computer, which is using http://repo.maven.apache.org working fine, no checksum errors.
I have been trying to change http://repo1.maven.org to http://repo.maven.apache.org but I cannot find where to change this.
I also wonder why different computers from same network got different repo to download and stuck with that repo forever.
Upvotes: 6
Views: 8634
Reputation: 5094
Default locations of your settings files are:
There are two locations where a settings.xml file may live:
- The Maven install: $M2_HOME/conf/settings.xml
- A user's install: ${user.home}/.m2/settings.xml
M2_HOME
is path to maven installation directory. The defaults can be found in the maven installation instructions:
C:\Program Files\Apache Software Foundation\apache-maven-3.1.0
/usr/local/apache-maven/apache-maven-3.1.0
or open command prompt/terminal and type:
echo %M2_HOME%
echo $M2_HOME
To change the location of your central repository its mirror can be defined. Open your settings.xml
and add:
<settings>
...
<mirrors>
<mirror>
<id>myMirrorId</id>
<name>mirror of a central repo</name>
<url>http://server</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
...
</settings>
Now when running maven from your project root folder with the debug output (-X
) you should see in the beggining of your console output:
[DEBUG] Using mirror myMirrorId (http://server) for central (http://repo.maven.apache.org/maven2).
The default central repo has id
central and that's why that is the value of mirrorOf
tag. My default central repo is the one you are trying to set.
I also wonder why different computers from same network got different repo to download.
If you comment everything in your user settings file (leave just the outer settings
tags) and have default global settings file (which is basically empty) running:
mvn help:effective-settings
will dump practically empty settings. When building project maven still knows the location of the central repo, because every pom file inherits from the super pom and that is where the default central repo URL is defined:
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>http://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
The super pom is located at $M2_HOME/lib/maven-model-builder-<VERSION>.jar
under /org/apache/maven/model/pom-4.0.0.xml
.
As Robert Scholte informed, as of 3.0.4 the default URL has been changed from http://repo1.maven.org/maven2
to http://repo.maven.apache.org/maven2
Upvotes: 4
Reputation: 12345
This was changed with Apache Maven 3.0.4, the related issue is MNG-5151
Upvotes: 6