Reference: Xu Xiaobin's "maven combat"
Mirroring is designed to provide faster service
X is considered to be a mirror of Y.
Edit Settings.xml Configure the Central warehouse Image:
[HTML]View Plaincopyprint?
- <settings>
- ...
- <mirrors>
- <mirror>
- <ID>maven.net.cn</ID>
- < name >one of the central mirrors in China</name>
- <URL>http://maven.net.cn/content/groups/public/</url>
- <mirrorof>central</mirrorof>
- </Mirror>
- </Mirrors>
- ...
- </Settings>
<mirrorof> is central, which indicates that this configuration is a mirrored , Any request for a central warehouse will be transferred to the mirror
Any required artifacts can be obtained from a single database, which is the mirror of all warehouses. At this point, you can configure a mirror such as the example:
[HTML]View Plaincopyprint?
- <settings>
- ...
- <mirrors>
- <mirror>
- <ID>internal-repository</ID>
- <name>internal Repository Manager</name>
- <URL>http://192.168.1.100/maven2</url>
- <mirrorof>*</mirrorof>
- </Mirror>
- </Mirrors>
- ...
- </Settings>
In this example , the value of <mirrorOf> is an asterisk, which means that the configuration is a mirror image of all maven warehouses, and any requests for remote warehouses will be forwarded to http://192.168.1.100/maven2/. If the mirror warehouse requires authentication, configure an <server> with an ID of internal-repository. To meet a number of complex requirements, MAVEN also supports more advanced mirroring configurations:
1.<mirrorOf>*</mirrorOf>
Matches all remote warehouses.
2.<mirrorOf>external:*</mirrorOf>
Match all remote warehouses except with localhost, except with the FILE://protocol. That is, match all remote warehouses that are not on this computer.
3.<mirrorof>repo1,repo2</mirrorof>
Match warehouses Repo1 and REPO2, separating multiple remote warehouses with commas.
4.<mirrorOf>*,!repo1</miiroOf>
Match all remote warehouses except REPO1, using an exclamation point to exclude the warehouse from the match.
It is important to note that because the mirrored warehouse is completely shielded from the mirrored warehouse, MAVEN will not be able to download artifacts when the mirrored warehouse is unstable or the service is stopped.
Maven Mirroring Configuration