文档章节

mave 配置文件里面的setting 配置仓库

Oscarfff
 Oscarfff
发布于 2016/02/08 12:14
字数 819
阅读 94
收藏 0
点赞 1
评论 0

Using Mirrors for Repositories

With Repositories 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:

<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 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 repository manager instead.

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

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 Repository Metadata. 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+.

<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 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+.

<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>

Creating Your Own Mirror

The size of the central repository is increasing steadily 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 repository manager as a proxy.

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


本文转载自:https://maven.apache.org/guides/mini/guide-mirror-settings.html

共有 人打赏支持
Oscarfff
粉丝 71
博文 804
码字总数 96913
作品 0
崇明
后端工程师
intellij IDEA开发工具项目maven管理

今天自己重新部署一下intellij下的项目开发环境,顺便把maven管理项目jar包的方法梳理一下 (1)首先下载apache-maven-3.0.4版本的maven,我自己解压在D:mavenapache-maven-3.0.4目录下,这里...

EDIAGD ⋅ 2013/01/29 ⋅ 4

如何在maven项目中正确引用自己打包的jar

1、通过mvn clean install,将项目的jar安装到了maven的本地仓库。 HelloWorld-0.0.1-SNAPSHOT.pom的内容如下:

霍艳超 ⋅ 2015/04/16 ⋅ 5

1分钟快速搭建maven

一、mave安装 mavn地址:http://maven.apache.org/download.cgi jdk:1.5以上 操作系统:windows(本文章) maven 下载之后直接解压即可。 二、环境配置 1、环境变量 以上直接在windows 的环境变量...

wier ⋅ 2015/03/03 ⋅ 0

maven几种常见错误的解决方法

一、must override a superclass method 错误 首先我们得知道: @override注释在jdk1.5环境下只能用于对继承的类的方法的重写,而不能用于对实现的接口中的方法的实现,在jdk1.6环境下对于继...

cjun1990 ⋅ 2015/01/14 ⋅ 0

Maven项目的配置和创建

在Java项目中,每个项目都有很多依赖的Jar包,我们一般都放在自己项目的lib目录中,这样就会导致同样的Jar包在各个不同的项目中重复出现,时间长了将会浪费很大的硬盘空间。使用Maven对项目进行...

JavaOlder ⋅ 2013/03/08 ⋅ 0

【Maven】项目管理利器Maven(三)——本地仓库、远程仓库(私服)和中央仓库

一、前言 在上一篇博客中,小编向大家介绍了如何安装和配置Maven,当然啦,我们配置好Maven后,就要看看它的配置文件了,配置文件中,就不得不提提文件里面配置的内容有什么了,在这篇博客中...

kisscatforever ⋅ 01/15 ⋅ 0

maven的安装以及在eclipse的配置和使用

1.本地安装maven 这个非常简单,就不配图了, 只用文字写就行了 (1)在Apache网站下载Maven2,下载地址:http://maven.apache.org/download.html,我下载的版本是:maven-2.2.1-bin.zip。 (...

双月通天 ⋅ 2015/08/18 ⋅ 1

Maven的使用,Nexus建立本地仓库以及Eclipse导入Maven项目(四): 实战篇

Maven的使用,Nexus建立本地仓库以及Eclipse导入Maven项目(四): 实战篇 项目实战篇: ================================================================ 下载项目 ------------------------......

DavyZhong ⋅ 2012/11/12 ⋅ 4

Maven:mirror和repository 区别

1 Repository(仓库) 1.1 Maven仓库主要有2种: remote repository:相当于公共的仓库,大家都能访问到,一般可以用URL的形式访问 local repository:存放在本地磁盘的一个文件夹,例如,w...

青木河 ⋅ 2013/01/07 ⋅ 12

配置 maven setting.xml 为国内(aliyun)的仓库 不生效

配置 maven setting.xml 为国内的仓库 不生效 maven的 setting文件默认是中央仓库地址,国外的,速度比较慢想换成国内的仓库地址:http://maven.aliyun.com/nexus/content/groups/public/但是...

zhaiguangtao ⋅ 2016/12/27 ⋅ 0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

windows profesional 2017 build problem

.net framework .... https://stackoverflow.com/questions/43330915/could-not-load-file-or-assembly-microsoft-build-frameworkvs-2017...

机油战士 ⋅ 44分钟前 ⋅ 0

python3中报错的解决方法(长期更新)

1、ImportError: No module named ‘DjangoUeditor’ 出错原因:安装DjangoUeditor库适用于python2,需要下载适用python3的 下载地址:https://github.com/twz915/DjangoUeditor3 2、python3......

xiaoge2016 ⋅ 48分钟前 ⋅ 0

数据结构与算法之双向链表

一、双向链表 1.双向链表的结点结构 typedef struct DualNode{ ElemType data; struct DualNode *prior; // 前驱结点 struct DualNode *next; // 后继结点}DualNode, *DuL...

aibinxiao ⋅ 今天 ⋅ 0

五大最核心的大数据技术

大数据技术有5个核心部分,数据采集、数据存储、数据清洗、数据挖掘、数据可视化。关于这5个部分,有哪些核心技术?这些技术有哪些潜在价值?看完今天的文章就知道了。 大数据学习群:7165810...

董黎明 ⋅ 今天 ⋅ 0

PhpStorm 头部注释、类注释和函数注释的设置

首先,PhpStorm中文件、类、函数等注释的设置在:setting-》Editor-》FIle and Code Template-》Includes下设置即可,其中方法的默认是这样的: /**${PARAM_DOC}#if (${TYPE_HINT} != "v...

nsns ⋅ 今天 ⋅ 0

spring.net AOP

http://www.springframework.net/doc-latest/reference/html/aop-quickstart.html https://www.cnblogs.com/wujy/archive/2013/04/06/3003120.html AOP系列(一)——ProxyFactoryObject 显式创......

whoisliang ⋅ 今天 ⋅ 0

【HAVENT原创】创建 Dockerfile 生成新的镜像,并发布到 DockerHub

注意:Win7 与 Win10 的版本存在差异,Win7 版本使用 Docker Quickstart Terminal 进入控制台,Win10下面直接用管理员权限打开控制台或者 PowerShell 即可;另外 Win7 下面只能访问 C盘,/ap...

HAVENT ⋅ 今天 ⋅ 0

pom.xml出现web.xml is missing ...解决方案

提示信息应该能看懂。也就是缺少了web.xml文件,<failOnMissingWebXml>被设置成true了。 搜索了一下,Stack Overflow上的答案解决了问题,分享一下。 目前被顶次数最多的回答原文如下: This...

源哥L ⋅ 今天 ⋅ 0

js时间戳与日期格式之间相互转换

1. 将时间戳转换成日期格式 1 2 3 4 5 6 7 8 9 10 11 12 13 14 // 简单的一句代码 var date = new Date(时间戳); //获取一个时间对象 /** 1. 下面是获取时间日期的方法,需要什么样的格式自己...

Jack088 ⋅ 今天 ⋅ 0

web添加log4j

添加xml配置log4j.properties # Global logging configuration---root日志设置#log4j.rootLogger=info,dailyRollingFile,stdoutlog4j.rootLogger=debug,stdout,dailyRollingFile---......

黄柳淞 ⋅ 今天 ⋅ 0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

返回顶部
顶部