Maven: Why is my computer always booting from http://repo1.maven.org?

I have two computers. One of them is always downloaded from http://repo1.maven.org . While the other is loading from http://repo.maven.apache.org .

Today, on the first computer, I received a checksum error on this 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 a second computer that uses http://repo.maven.apache.org , it works fine, no checksum errors.

I am trying to change http://repo1.maven.org to http://repo.maven.apache.org , but I cannot find where to change it.

I also wonder why different computers from the same network got different repos in order to download and get stuck with this repo forever.

+4
source share
2 answers

This has been changed since Apache Maven 3.0.4, related issue MNG-5151

+5
source

The default location of your settings files is:

There are two places where the settings.xml file can be:

  • Maven installation: $ M2_HOME / conf / settings.xml
  • Custom Installation: $ {user.home} /. m2 / settings.xml

M2_HOME is the path to the maven installation directory. The default values ​​can be found in the maven installation instructions :

  • win xp / 2k: C:\Program Files\Apache Software Foundation\apache-maven-3.1.0
  • unix: /usr/local/apache-maven/apache-maven-3.1.0

or open a command prompt / terminal and enter:

  • win xp / 2k: echo %M2_HOME%
  • unix: echo $M2_HOME

To change the location of the central repository, you can define its mirror. Open 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 you start maven from the project root folder with debug output ( -X ), you should see at the beginning of your console output:

 [DEBUG] Using mirror myMirrorId (http://server) for central (http://repo.maven.apache.org/maven2). 

The central repo defaults to id central, and why is the value of the mirrorOf tag. The default central repo is the one you are trying to install.

I also wonder why different computers from the same network got different repos to boot.

If you comment on everything in your user settings file (leave only the external settings tags) and save the default global settings file (which is mostly empty):

 mvn help:effective-settings 

resets almost empty settings. When creating a project, maven still knows the location of the central repo, because each pom file is inherited from super pom , and that is where the default repo central URL is used:

 <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> 

Super pom is located in $M2_HOME/lib/maven-model-builder-<VERSION>.jar under /org/apache/maven/model/pom-4.0.0.xml .

According to Robert Scholte, from 3.0.4 the default URL has been changed from http://repo1.maven.org/maven2 to http://repo.maven.apache.org/maven2

+2
source

Source: https://habr.com/ru/post/1499197/


All Articles