在 POM 中配置:

 <project>
...
<repositories>
<repository>
<id>nexus</id>
<name>Nexus</name>
<url>http://10.70.8.36:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>Nexus</name>
<url>http://10.70.8.36:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
...
</project>

在 settings.xml 中配置:

settings.xml 并不支持直接配置 repositories 和 pluginRepositories,Maven 提供了 profile 机制,能让为用户将仓库配置放到 settings.xml 中的 profile 中。

 <settings>
...
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus</id>
<name>Nexus</name>
<url>http://10.70.8.36:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>Nexus</name>
<url>http://10.70.8.36:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles> <activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
...
</settings>

该配置中使用用一个  <id>  为 nexus 的  <profile> ,这个 profile 包含了相关的仓库配置,同时配置中又使用  <activeProfile>  将 nuxus 这个 profile 激活,这样当执行 Maven 构建的时候,激活的 profile 会将仓库配置应用到项目中去。

配置了上述配置,Maven 除了从 Nexus 下载构件之外,还会不时地访问中央仓库 central,如果希望所有 Maven 下载请求都仅仅通过 Nexus,这个时候需要配置镜像。

 <settings>
...
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
    <url>http://10.70.8.36:8081/nexus/content/groups/public/</url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus</id>
<name>Nexus</name>
<url>http://10.70.8.36:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>Nexus</name>
<url>http://10.70.8.36:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles> <activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
...
</settings>

仓库及插件仓库配置的 id 都是 central,他们覆盖了超级 POM 中央仓库的配置,它们的 url 已经无关紧要,因为所有的请求都会通过镜像访问私服地址。配置仓库及插件仓库的主要目的是开启对快照版本下载的支持,当 Maven 需要下载发布版或快照版构件的时候,它首先检查 central,看该类型的构件是否支持,得到正面的回答之后,再根据镜像匹配规则转而访问私服仓库地址。

Maven--配置 Maven 从 Nexus 下载构件的更多相关文章

  1. 安装maven配置maven环境变量

    在官网下载maven的包 我们下载的是:apache-maven-3.5.2-bin.zip 3.解压缩maven的包到某个目录中 4.配置maven的环境变量 配置M2_HOME环境变量为maven ...

  2. 【项目管理和构建】十分钟教程,eclipse配置maven + 创建maven项目(三)

    [项目管理和构建]十分钟教程,eclipse配置maven + 创建maven项目(三) 上篇博文中我们介绍了maven下载.安装和配置(二),这篇博文我们配置一下eclipse,将它和maven结合 ...

  3. eclipse配置maven + 创建maven项目(三)

    上篇博文中我们介绍了maven下载.安装和配置(二),这篇博文我们配置一下eclipse,将它和maven结合,并我们创建一个maven的项目. 准备工作 在eclipse配置maven之前需要我们做 ...

  4. maven win 安装 与 IntelliJ IDEA 配置Maven【2018-11-14最新最有姿势攻略】

    [博客园cnblogs笔者m-yb原创,转载请加本文博客链接,笔者github: https://github.com/mayangbo666,公众号aandb7,QQ群927113708] http ...

  5. 在 IDEA 中 配置 Maven

    1.从 Maven官网下载 最新版的 Maven  2.设置Java相关环境变量 JAVA_HOME       AVA_HOME=C:\jdk1.5.0_06 PATH                ...

  6. Maven学习总结(一副本)——Maven配置和搭建

    环境准备: JDK 1.6 Maven 3.0.4 myeclipse 8.6.1 安装 Maven 之前要求先确定你的 JDK 已经安装配置完成.Maven是 Apache 下的一个项目,目前最新版 ...

  7. eclipse配置maven + 创建maven项目

        登录|注册     努力+坚持,而且还很年轻   目录(?)[+] 在现实的企业中,以低成本.高效率.高质量的完成项目,不仅仅需要技术大牛,企业更加需要管理大牛,管理者只懂技术是远远不够的.当 ...

  8. Java 笔记——在 IDEA 中使用 Maven 配置和使用 MyBatis

    1.前言 MyBatis 是什么? MyBatis 是一款优秀的持久层框架,它支持定制化 SQL.存储过程以及高级映射. MyBatis 避免了几乎所有的 JDBC 代码和手动设置参数以及获取结果集. ...

  9. maven(2)------maven构建项目

    一  下载maven 官网地址: http://maven.apache.org/download.cgi 如图: 可以下载历史版本. 二 windows下maven配置 1. 解压下载后的包,解压后 ...

随机推荐

  1. HDU - 6000 Wash(优先队列+贪心)

    题意:已知有L件衣服,M个洗衣机,N个烘干机,已知每个机器的工作时间,且每个机器只能同时处理一件衣服,问洗烘完所有衣服所需的最短时间. 分析: 1.优先队列处理出每件衣服最早的洗完时间. 2.优先队列 ...

  2. 3D打印技术的火爆,真的会让传统模具行业没落吗?

    当一种新生事物出现时,人们除了赞美它带来的新畅想外,往往还会对"旧事物"贬低几分--各种淘汰观点总是不绝于耳.但可惜的是,新生事物取代旧事物的事儿并不会必然发生.比如,直到现在广播 ...

  3. centos6.7开启linux虚拟机内部错误

    如图 这个需要用管理员身份运行就好了 右键----->以管理员身份打开,正常启动

  4. 关于linux 交叉编译器的安装

    找了几个贴 https://www.cnblogs.com/uestc-mm/p/6656325.html 这个最好

  5. Day4-T4

    原题目 Describe:建个图,连通后删边 [ 如果把 !dis[i][j] 全部定义为INF会更好理解 ] .先特判,再贪心求总数 code: #pragma GCC optimize(2) #i ...

  6. 计算机操作系统学习(一) Linux常用指令(随时更新)

    1.chmod 以下转载至https://blog.csdn.net/summer_sy/article/details/70142475 chmod u+x file.sh 就表示对当前目录下的fi ...

  7. (转)解决windows解决windows 7 部分程序图标显示不正常的问题

    刚解决计算机的管理选项打开出现问题,又发现系统里部分程序的快捷图标显示不出了, 曾在xp里也出现过同样的问题,常理推断,如果系统没有被病毒破坏那可能就是系统图标缓存出现问题 因此,双管齐下,一边检查系 ...

  8. TensorFlow2 Part1:基础

    TensorFlow™是一个基于数据流编程(dataflow programming)的符号数学系统,被广泛应用于各类机器学习(machine learning)算法的编程实现,其前身是谷歌的神经网络 ...

  9. 137-PHP static修饰的类属性

    <?php class test{ //定义一个类 public static $num=0; //定义static修饰的类属性 public function __construct(){ / ...

  10. RabbitMQ整合Spring Booot【消费者补偿幂等问题】

    如果消费者 运行时候 报错了 package com.toov5.msg.SMS; import org.springframework.amqp.rabbit.annotation.RabbitHa ...