Maven repositories are generally divided into local and remote repositories. Remote warehouse is divided into private server, central warehouse, central warehouse mirror warehouse.
A local repository is a locally maintained Maven repository that serves only native projects.
A private server is typically a Maven repository set up by a company or organization at the LAN level to serve members of the company or organization’s LAN.
Mirror repository, by which I mean the mirror repository of Maven’s central repository. Located all over the globe, it is a mirror backup of Maven’s central repository. The role of the mirror warehouse is to distribute the load of access to the central warehouse, and the second is to speed up the download of dependencies. Commonly used mirror warehouse ali cloud mirror warehouse and so on.
So in real development, with multiple repositories configured, what is the load access order between them?
Local warehouse “private server” mirror warehouse
This can be verified by configuration: pom.xml configuration repository:
<repositories>
<repository>
<id>local-nexus</id>
<url>http://xxx.xxx.xxx.135:8081/nexus/repository/maven-group-snapshots/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>ali-maven</id>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
Copy the code
Setting.xml configuration repository:
<! -- Here we configure ali Cloud mirror repository to replace Maven central repository -->
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
Copy the code
The compile it:
. [DEBUG] Using local repository at D:\programs\apache-maven-3.6.1-bin\notify_repo [DEBUG] Using manager EnhancedLocalRepositoryManager with priority for 10.0 D: \ designed \ apache maven - 3.6.1 track - bin \ notify_repo INFO for Scanning projects... [DEBUG] Using mirror alimaven [DEBUG] Using mirror alimaven [DEBUG] Using mirror alimaven (http://maven.aliyun.com/nexus/content/groups/public/) for central (https://repo.maven.apache.org/maven2). ...Copy the code
. // We can see that this is the order in which the remote repository is loaded. First we load the 135 private server configured by pop.xml, then we load ali-maven, and finally we load alimavn in setting.xml. [DEBUG] Repositoriesrepositories (Dependencies) [local-nexus (http://xxx.xxx.xxx.135:8081/nexus/repository/maven-group-snapshots/, default, releases+snapshots), ali-maven (http://maven.aliyun.com/nexus/content/groups/public/, default, releases+snapshots), alimaven (http://maven.aliyun.com/nexus/content/groups/public/, default, releases)] ...Copy the code
This and setting.xml are not representative of all configurations that actually occur. The exact loading order depends on the project and Maven configuration. These are not important.
Finally, how to enable Maven debug level logging in IDEA: