Maven--配置 Maven 从 Nexus 下载构件
在 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 下载构件的更多相关文章
- 安装maven配置maven环境变量
在官网下载maven的包 我们下载的是:apache-maven-3.5.2-bin.zip 3.解压缩maven的包到某个目录中 4.配置maven的环境变量 配置M2_HOME环境变量为maven ...
- 【项目管理和构建】十分钟教程,eclipse配置maven + 创建maven项目(三)
[项目管理和构建]十分钟教程,eclipse配置maven + 创建maven项目(三) 上篇博文中我们介绍了maven下载.安装和配置(二),这篇博文我们配置一下eclipse,将它和maven结合 ...
- eclipse配置maven + 创建maven项目(三)
上篇博文中我们介绍了maven下载.安装和配置(二),这篇博文我们配置一下eclipse,将它和maven结合,并我们创建一个maven的项目. 准备工作 在eclipse配置maven之前需要我们做 ...
- maven win 安装 与 IntelliJ IDEA 配置Maven【2018-11-14最新最有姿势攻略】
[博客园cnblogs笔者m-yb原创,转载请加本文博客链接,笔者github: https://github.com/mayangbo666,公众号aandb7,QQ群927113708] http ...
- 在 IDEA 中 配置 Maven
1.从 Maven官网下载 最新版的 Maven 2.设置Java相关环境变量 JAVA_HOME AVA_HOME=C:\jdk1.5.0_06 PATH ...
- Maven学习总结(一副本)——Maven配置和搭建
环境准备: JDK 1.6 Maven 3.0.4 myeclipse 8.6.1 安装 Maven 之前要求先确定你的 JDK 已经安装配置完成.Maven是 Apache 下的一个项目,目前最新版 ...
- eclipse配置maven + 创建maven项目
登录|注册 努力+坚持,而且还很年轻 目录(?)[+] 在现实的企业中,以低成本.高效率.高质量的完成项目,不仅仅需要技术大牛,企业更加需要管理大牛,管理者只懂技术是远远不够的.当 ...
- Java 笔记——在 IDEA 中使用 Maven 配置和使用 MyBatis
1.前言 MyBatis 是什么? MyBatis 是一款优秀的持久层框架,它支持定制化 SQL.存储过程以及高级映射. MyBatis 避免了几乎所有的 JDBC 代码和手动设置参数以及获取结果集. ...
- maven(2)------maven构建项目
一 下载maven 官网地址: http://maven.apache.org/download.cgi 如图: 可以下载历史版本. 二 windows下maven配置 1. 解压下载后的包,解压后 ...
随机推荐
- Problem J. Joseph’s Problem 约瑟夫问题--余数之和
链接:https://vjudge.net/problem/UVA-1363 题意:给出n k,当 i 属于 1~n 时 ,求解 n% i 的和 n 和 k 的范围都是 1 到 10^9; 商相同 ...
- 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包
将项目复制到其地方的时候编译会报错,按照官网方法也不行,从网上查了一个有用的方法如下 打开CSPROJ文件.删除如下代码, <Import Project="..\packages\ ...
- chrome常用参数
chrome禁止本地浏览时加载本地其他文件,可以采用添加启动参数的方式来支持 添加参数为 --allow-file-access-from-files 或者 --disable-web-securit ...
- 文本编辑器vim/vi——末行模式
指令格式: #vim 文件路径作用:打开指定的文件. 进入方式:由命令模式进入,按下“:”或者“/(表示查找)”即可进入 退出方式: a. 按下esc b. 连按2次esc键 c. 删除末行全部输入字 ...
- 聊一聊Java中的各种运算符(转载)
计算机之所以叫"计算机",其最基本用途之一就是运算,对应刚刚接触Java的小伙伴而言,熟悉并掌握Java中的各种运算符及其在表达式中的运算优先级是十分必要的. 算术运算 算术运算主 ...
- opencv python训练人脸识别
总计分为三个步骤 一.捕获人脸照片 二.对捕获的照片进行训练 三.加载训练的数据,识别 使用python3.6.8,opencv,numpy,pil 第一步:通过笔记本前置摄像头捕获脸部图片 将捕获的 ...
- pycharm 设置项目的编译器
设置编译器(interpreter) File---Setting--在搜索框输入(interpreter)
- Bean 注解(Annotation)配置(3)- 依赖注入配置
Spring 系列教程 Spring 框架介绍 Spring 框架模块 Spring开发环境搭建(Eclipse) 创建一个简单的Spring应用 Spring 控制反转容器(Inversion of ...
- css 基础知识 (待完善...)
CSS 1.position 属性 对元素进行定位. absolute 相对于 非static类型的position 的 第一个(临近的) 父元素 进行定位. ...
- jar类库加载顺序
当我们启动一个tomcat的服务的时候,jar包和claess文件加载顺序: 1. $java_home/lib 目录下的java核心api 2. $java_home/lib/ext 目录下的jav ...