在 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. 载域和运行域的理解(ARM程序是怎么运行的)

    对ARM加载域和运行域的理解 一般而言,一个程序包括只读的代码段和可读写的数据段.在ARM的集成开发环境中,只读的代码段和常量被称作RO段(ReadOnly):可读写的全局变量和静态变量被称作RW段( ...

  2. RadioButton之互斥选择和Toast显示

    前言: RadioButton用来单选并且用Toast来进行提示所选内容 RadioButton标签单独写的时候不能出现互斥现象,代码如下 <RadioButton android:layout ...

  3. 一百零八、SAP的OO-ALV之二,创建屏幕Screen

    一.在资源管理器,右键->创建屏幕 二.输入4位数字 三.输入屏幕的描述 四.在逻辑流里面PBO用于显示屏幕,PAI用于用户交互. 五.在元素清单里面,在屏幕中的所有元素都是在元素清单中的

  4. 设置进程用指定IE版本

    function IsWOW64: BOOL; begin Result := False; if GetProcAddress(GetModuleHandle(kernel32), 'IsWow64 ...

  5. kafka cmd with ssl

    set PATH=C:\Program Files\Java\jdk1.8.0_201\bin;@call kafka-consumer-groups.bat --bootstrap-server l ...

  6. 本地的jar包导入到maven仓库

    需要引入本地jar,然后百度跟着教程实现了,做个记录加深印象.https://www.cnblogs.com/lixuwu/p/5855031.html 1首先找到要传入maven的jar包(放在一个 ...

  7. c++程序—if语句实践

    三只小 #include<iostream> using namespace std; #include<string> int main() { //which pig is ...

  8. ffmpeg 模块简介

    FFmpeg 是一套可以用来记录.转换数字音频.视频,并能将其转化为流的开源计算机程序.它包括了领先的音/视频编码库libavcodec 等.libavformat:用于各种音视频封装格式的生成和解析 ...

  9. MFC 根据字符宽度居中

    Gdiplus::Font font(_T("微软雅黑"), (Gdiplus::REAL)130); Gdiplus::RectF orgin(0.0f, 100.0f, nWi ...

  10. 用AD 输出BOM时提示failed to open excel template

    解决办法: 去掉这个√!