Maven Learning Warehouse Image

Source: Internet
Author: User
Tags maven central

Using Warehouse Mirroring

Warehouses can be declared in a project, but sometimes you might want to use the image of a warehouse without modifying the project file.

Reasons for using mirroring:

    • has a synchronous mirror and is faster.
    • You want to use your own internal warehouses that you control.
    • You want to run Repository Manager to provide a local cache (mirror), and then use the cached URL.

In order to configure the image for a given warehouse, you need to provide the ID and URLof the new warehouse in ${user.home}/.m2/settings.xml and specify the value of mirrorof - -Is the IDof the repository you want to mirror.

For example, the ID of the Maven Central US Warehouse is centrally, so if you want to use the European Central Warehouse, you can configure this:

<Settings>    ...    <Mirrors>        <Mirror>            <ID>UK</ID>            <name>UK Central</name>            <URL>Http://uk.maven.org/maven2</URL>            <mirrorof>Central</mirrorof>        </Mirror>    </Mirrors>    ...</Settings>

Note that there can be at most one mirror for a given warehouse. That is, no matter how many mirrors, the value of its <mirrorOf> cannot be repeated! MAVEN does not aggregate the image, but simply picks out the first one that fits. If you want to provide a view that consists of multiple warehouses, use a repository manager.

The Settings descriptor documentation can be found on the Maven Local settings Model Website.

Note: The official Maven 2 warehouse is http://repo.maven.apache.org/maven2 located in the United States, or Http://uk.maven.org/maven2 is located in the UK.

There is a known list of mirrors in the Repository Metadata. The contents of these images may vary, and we (MAVEN official) will not support them in any way.

Use a separate warehouse

You can force Maven to use a separate warehouse-by having the warehouse mirror all of the warehouse requests. The repository must contain all required artifacts, or be able to proxy requests to other warehouses. This is useful when using an intercompany warehouse, which can be used to proxy external requests using MAVEN Repository Manager.

Just set the value of <mirrorOf> to *!

Note: This feature only supports Maven 2.0.5+.

<Settings>    ...    <Mirrors>        <Mirror>            <ID>Internal-repository</ID>            <name>Maven Repository Manager running on repo.mycompany.com</name>            <URL>Http://repo.mycompany.com/proxy</URL>            <mirrorof>*</mirrorof>        </Mirror>    </Mirrors>    ...</Settings>

Advanced Mirroring Guide

When mated with Repository manager, a single mirror can handle multiple warehouses.

This syntax comes from Maven 2.0.9:

    • * match all the warehouse IDs.
    • external:* matches all warehouses except those that use localhost or file-based repositories. When you want to exclude redirected warehouses (for integration testing), you can use them with Repository Manager.
    • , multiple warehouses can be spliced using commas.
    • ! It can be used with one of the wildcard characters mentioned above to exclude a warehouse ID.

In the list of warehouse identifiers in the comma interval, the wildcard location is not as good as ... (long sentences, too lazy to translate) important.

The position of wildcards within a comma separated list of repository identifiers is not important as the wildcards defer To further processing and explicit includes or excludes stop the processing, overruling any wildcard match.

When you use advanced syntax and configure multiple mirrors, keep in mind that their declaration order is not irrelevant. When Maven looks for a mirror for a warehouse, it checks the <mirrorOf> most matched image first. If there is no direct match, MAVEN uses the first declared image-in accordance with the above-mentioned rules, if any.

Example:

    • * stands for arbitrary.
    • The external:* represents any not on localhost, or is not file-based.
    • Repo,repo1 represents repo or REPO1.
    • *,!REPO1 stands for arbitrary, but except REPO1.

Note that this feature only supports Maven 2.0.9+.

<Settings>    ...    <Mirrors>        <Mirror>            <ID>Internal-repository</ID>            <name>Maven Repository Manager running on repo.mycompany.com</name>            <URL>Http://repo.mycompany.com/proxy</URL>            <mirrorof>External:*,!foo</mirrorof>        </Mirror>        <Mirror>            <ID>Foo-repository</ID>            <name>Foo</name>            <URL>Http://repo.mycompany.com/foo</URL>            <mirrorof>Foo</mirrorof>        </Mirror>    </Mirrors>    ...</Settings>

Create your own image

The size of the central warehouse is growing steadily. In order to save our bandwidth and your time, mirroring the entire central repository is not allowed. (This will be automatically banned) instead, we recommend that you set up a repository manager as a proxy.

If you want to be an official image, please contact us.

Official Documentation Links:

Http://maven.apache.org/guides/mini/guide-mirror-settings.html

Maven Learning Warehouse Image

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.