博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
mave 配置文件里面的setting 配置仓库
阅读量:7111 次
发布时间:2019-06-28

本文共 5297 字,大约阅读时间需要 17 分钟。

hot3.png

Using Mirrors for Repositories

With  you specify from which locations you want to download certain artifacts, such as dependencies and maven-plugins. Repositories can be declared inside a project, which means that if you have your own custom repositories, those sharing your project easily get the right settings out of the box. However, you may want to use an alternative mirror for a particular repository without changing the project files.

Some reasons to use a mirror are:

  • There is a synchronized mirror on the internet that is geographically closer and faster

  • You want to replace a particular repository with your own internal repository which you have greater control over

  • You want to run a repository manager to provide a local cache to a mirror and need to use its URL instead

To configure a mirror of a given repository, you provide it in your settings file (${user.home}/.m2/settings.xml), giving the new repository its own id and url, and specify the mirrorOf setting that is the ID of the repository you are using a mirror of. For example, the ID of the main Maven Central US repository included by default is central, so to use the European Central instance, you would configure the following:

  ...  
    
      
UK
      
UK Central
      
http://uk.maven.org/maven2
      
central
    
  
  ...

Note that there can be at most one mirror for a given repository. In other words, you cannot map a single repository to a group of mirrors that all define the same <mirrorOf> value. Maven will not aggregate the mirrors but simply picks the first match. If you want to provide a combined view of several repositories, use a  instead.

The settings descriptor documentation can be found on the .

Note: The official Maven 2 repository is at http://repo.maven.apache.org/maven2 hosted in the US, or http://uk.maven.org/maven2 hosted in the UK.

A list of known mirrors is available in the . These mirrors may not have the same contents and we don't support them in any way.

Using A Single Repository

You can force Maven to use a single repository by having it mirror all repository requests. The repository must contain all of the desired artifacts, or be able to proxy the requests to other repositories. This setting is most useful when using an internal company repository with the Maven Repository Manager to proxy external requests.

To achieve this, set mirrorOf to *.

Note: This feature is only available in Maven 2.0.5+.

  ...  
    
      
internal-repository
      
Maven Repository Manager running on repo.mycompany.com
      
http://repo.mycompany.com/proxy
      
*
    
  
  ...

Advanced Mirror Specification

A single mirror can handle multiple repositories when used in conjunction with a repository manager.

The syntax as of Maven 2.0.9:

  • * matches all repo ids.

  • external:* matches all repositories except those using localhost or file based repositories. This is used in conjunction with a repository manager when you want to exclude redirecting repositories that are defined for Integration Testing.

  • multiple repositories may be specified using a comma as the delimiter

  • an exclamation mark may be used in conjunction with one of the above wildcards to exclude a repository id

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 the advanced syntax and configure multiple mirrors, keep in mind that their declaration order matters. When Maven looks for a mirror of some repository, it first checks for a mirror whose <mirrorOf> exactly matches the repository identifier. If no direct match is found, Maven picks the first mirror declaration that matches according to the rules above (if any). Hence, you may influence match order by changing the order of the definitions in the settings.xml

Examples:

  • * = everything

  • external:* = everything not on the localhost and not file based.

  • repo,repo1 = repo or repo1

  • *,!repo1 = everything except repo1

Note: This feature is only available in Maven 2.0.9+.

  ...  
    
      
internal-repository
      
Maven Repository Manager running on repo.mycompany.com
      
http://repo.mycompany.com/proxy
      
external:*,!foo
    
    
      
foo-repository
      
Foo
      
http://repo.mycompany.com/foo
      
foo
    
  
  ...

Creating Your Own Mirror

The size of the central repository is  To save us bandwidth and you time, mirroring the entire central repository is not allowed. (Doing so will get you automatically banned) Instead, we suggest you setup a  as a proxy.

If you really want to become an official mirror, contact us at  with your location and we'll work to get you setup.

转载于:https://my.oschina.net/u/2308739/blog/614315

你可能感兴趣的文章
DNS域名解析过程 五月的仓颉
查看>>
Comment Mail Notify:适用于Twenty Ten主题的WordPress评论邮件回复代码
查看>>
java程序员学习c++的感觉
查看>>
android中Handler详解
查看>>
如何在腾讯云快速构建一个Wordpress个人站点
查看>>
nginx与tomcat结合,动静分离
查看>>
IP Source Guard
查看>>
jvm学习-垃圾收集
查看>>
linux用文件锁实现保证一个程序只能启动一个进程
查看>>
使用wget工具抓取网页和图片
查看>>
linux下oracle开机启动
查看>>
【Linux命令】对抗遗忘 -ls 命令系列
查看>>
MyEclipse launch configuration 的清除
查看>>
各大互联网公司架构演进之路汇总
查看>>
js 改变地址栏中的url
查看>>
rsync+inotify
查看>>
我的友情链接
查看>>
F5 wireshark plugin
查看>>
MySQL企业版之优势
查看>>
我的友情链接
查看>>