Maven全局配置

Maven的全局配置文件是Maven安装目录conf/settings.xml文件,该文件可以配置仓库、代理、profile、镜像、插件等

<settings>
      <localRepository/>
      <interactiveMode/>
      <offline/>
      <pluginGroups/>
      <proxies/>
      <servers/>
      <mirrors/>
      <profiles/>
      <activeProfiles/>
</settings>

localRepository

本地仓库地址,默认情况下,下载到本地的代码库存放在${user.home}/.m2/repository文件夹中的,用户如果想存在放其他地方,配置该属性即可

interactiveMode

用户交互模式,默认为true

offline

是否在离线状态下运行,如果系统需要在离线状态下运行,则设置为true,默认为false

pluginGroups

插件组,当插件的groupId没有显式提供时,供搜寻插件(groupId)的列表

 <pluginGroups>
    <pluginGroup>org.mortbay.jetty</pluginGroup>
</pluginGroups>

proxies

代理,主要是为了便于在各自网络环境下使用

<proxies>
   <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
</proxy>
</proxies>

servers

服务配置,主要是针对需要鉴权的仓库的配置,有些仓库默认匿名用户可以访问,但是可能存在一些私服需要对用户进行鉴权,有相关权限的用户才可以继续访问或者操作。

<servers>
   <server>
      <id>deploymentRepo</id>
      <username>repouser</username>
      <password>repopwd</password>
</server>
</servers>

mirrors

镜像地址,对仓库地址的一种映射关系,国外的仓库地址可能不是很稳定,类似于AliBaBa和OSchina搭建的镜像地址,我们可以配置镜像地址,使得访问速度更快

<mirrors>
  <mirror>
     <id>nexus</id>
     <mirrorOf>central</mirrorOf>
     <name>My Maven repository</name>
     <url>http://localhost:8082/nexus/content/groups/public</url>
  </mirror>
</mirrors>

没有镜像的时候
需要直连A仓库,如果A仓库在国外可能存在各种问题不稳定工作

有镜像的时候
这时候存在一个B镜像,可以间接的访问到国外不稳定的A仓库,那我们加入B镜像就可以了

 

posted @ 2017-12-10 22:42  南极冰川雪  阅读(1982)  评论(0编辑  收藏  举报