A detailed description of Maven

The execution order maven repository:

  • settings_mirror higher priority than central
  • settings_profile_repo higher priority than settings_mirror
  • settings_profile_repo higher priority than pom_repositories
  • settings_profile_repo higher priority than pom_profile_repo
  • pom_profile_repo higher priority than pom_repositories
  • pom_repositories higher priority than settings_mirror

Come to a complete search chain by the above comparison:

local_repo > settings_profile_repo > pom_profile_repo > pom_repositories > settings_mirror > central

Note:

0, in the order in the plurality of mirror; a first bag or jar mirrorOf did not stop, the second will be performed;

1, at the same time mirrorOf with repositoryId priority is to address the use of mirror

2, mirrorOf * equal time to cover all the configuration repository

3 when there is a plurality of mirror configurations mirrorOf into equal * Finally, if a plurality of *, it is executed in the order;

4, only for the central configuration mirrorOf when you can not configure the repository

 

1 Repository (warehouse)

 

1.1 Maven repository There are two kinds:

  • remote repository: the equivalent of a public warehouse, everyone can have access to, you can generally be accessed using the URL of the form
  • local repository: local disk is stored in a file folder, for example, the default windows is C:. \ Users \ {username} \ m2 \ repository directory

1.2 Remote Repository mainly three kinds:

  • Central warehouse: http: //repo1.maven.org/maven2/ 
  • PW: self-built network maven repository, which is an internal Web site URL 
  • Other public warehouse: Other public can access the Internet maven repository, for example jboss repository, etc.

repository is stored in a variety of packages and jar maven plugin. When the warehouse request plug-in or dependent, will first check the local repository, if the local repository has directly returned, otherwise it will request to the remote repository, and cached to local repository. You can also do things into the local repository for local use only; or uploaded to a remote warehouse, for everyone to use. 

2 Mirror

mirror corresponds to an interceptor, it will intercept the request for the relevant maven remote repository and a remote repository in the request address, the address is redirected to the mirror in the configuration.

2.1 is not configured mirror:

 

2.2 Configuration mirror:

 

In this case, B Repository A Repository is called mirroring.

If all the contents of the warehouse X can provide warehouse storage Y, then X can be considered to be a mirror image of Y. In other words, any member may be a Y obtained from the warehouse, both Hu be obtained from its mirror image.

2.3 <mirrorOf></mirrorOf> 

<MirrorOf> </ mirrorOf> tag is to be placed inside mirrored Repository ID. In order to meet the needs of complex, Maven also supports more advanced mirror configuration: 

  • <mirrorOf>*</mirrorOf> 

            Matches all remote repository. 

  • <mirrorOf>repo1,repo2</mirrorOf> 

            Matching warehouse repo1 and repo2, use commas to separate multiple remote repository. 

  • <mirrorOf>*,!repo1</miiroOf> 

            All matches except the remote repository, repo1, use the exclamation point will be excluded from the match in the warehouse. 

3 Repository与Mirror

3.1 Definitions

In fact, mirror represents the relationship between the two Repository, the maven configuration file (setting.xml) is well equipped <mirrors> <mirror> .......... </ mirror> </ mirrors> , i.e. the definition of the mirroring relationship between the two Repository.

3.2 The purpose

Configuring mirroring relationship between the two Repository, typically for access speed and download speed consideration.

For example, there is a project that requires both coding and shelter in the company, and configure the project pom.xml A Maven repository. In the company, the telecommunications network, access A library quickly, so management maven dependencies and plugins are downloaded from A library; at home, Netcom network, access A library is very slow, but quickly access the B library. In this case, setting.xml residence, as long as the configuration at <mirrors> <mirror> .... </ mirror> </ mirrors>, let B be the mirror A database library, you can not change the project pom.xml a configuration for in the library.

If the image repository requires authentication, the configuration setting.xml <server> </ server> to.

3.3 Note

It should be noted that, due to completely shield the warehouse mirror mirrored warehouse, the warehouse when the image is unstable or stop services, Maven will still be unable to access the image repository, and therefore will not be able to download components.

4 PW

PW is a special remote Maven repository, it is set up in the LAN warehouse services, PW is generally configured to mirror the Internet remote repository for Maven LAN users to use.

When the need to download Maven member, Xianxiang PW request, if the member does not exist on the PW, the remote repository to download from the outside, while on the PW cache, then download Maven download request for the service, In addition, the custom or a third party jar can be uploaded from local to PW, maven for other users within the LAN.

The main advantages are:

  1. Save external network broadband
  2. Accelerate the Maven build
  3. The deployment of third-party components
  4. Improve stability, enhanced control: The reason is outside the network unstable
  5. Reduce the load on the central warehouses: the reason is too big central warehouse access

 

PS: Maven repository schematic

 

Published 57 original articles · won praise 15 · views 40000 +

Guess you like

Origin blog.csdn.net/qq_41694906/article/details/104337416