配置Maven从私服下载构件
来源:互联网 发布:上帝已死 知乎 编辑:程序博客网 时间:2024/05/29 17:01
--------------------siwuxie095
配置 Maven 从私服下载构件
从 Nexus 私服下载构件的配置方法共有三种
1、法一:
在 pom.xml 的project 标签中添加如下内容
<repositories>
<repository>
<id>nexus</id>
<name>Nexus</name>
<url>http://localhost: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://localhost:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
注:分别配置仓库和插件仓库
2、法二:
(1)在 settings.xml 的profiles 标签中添加如下内容
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus</id>
<name>Nexus</name>
<url>http://localhost: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://localhost:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
注:使用 id 为nexus 的 profile 分别配置仓库和插件仓库
(2)在 settings.xml 的activeProfiles 标签中添加如下内容
<activeProfile>nexus</activeProfile>
注:将 id 为 nexus 的 profile激活
3、法三(建议):
(1)在 settings.xml 的mirrors 标签中添加如下内容
<mirror>
<id>nexus</id>
<name>Nexus</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<mirrorOf>*</mirrorOf>
</mirror>
注:配置一个匹配任何仓库的镜像,其地址为 Nexus 私服
(2)在 settings.xml 的profiles 标签中添加如下内容
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<name>Central</name>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<!-- ++++++++++++++++++++++++++ -->
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Central</name>
<url>http://central</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
注:使用 id 为nexus 的 profile 分别配置仓库和插件仓库,
但仓库和插件仓库的 id 都为central,这将覆盖超级 POM
中央仓库的配置,而 url 已无关紧要,因为所有的请求都会
通过镜像访问私服地址
配置仓库和插件仓库的主要目的是开启对快照版本构件下载
的支持
(3)在 settings.xml 的activeProfiles 标签中添加如下内容
<activeProfile>nexus</activeProfile>
注:将 id 为 nexus 的 profile激活
附:
法一
针对当前 Maven 项目
法二
针对所有 Maven 项目
法三
针对所有 Maven 项目
法二和法三虽然都可以一劳永逸,但法二除了从 Nexus 私服
下载构件之外,还会不时访问中央仓库
我们希望的是所有 Maven 下载请求都仅仅通过 Nexus 私服,
以全面发挥私服的作用,而法三刚好做到了这点
【made by siwuxie095】
- 配置Maven从私服下载构件
- 配置Maven从Nexus下载构件
- 配置Maven从Nexus下载构件 ----学习笔记
- 从Maven私服引入开发所需构件教程
- Maven客户端只能通过Nexus私服下载Jar包构件
- 11 Mavne-配置从NEXUS下载构件和为项目配置独立仓库
- Nexus私服修改构件(Jar包)下载文件夹路径
- Maven无法从nexus私服下载依赖?
- J2ee项目从0搭建(二):Maven下载、安装、eclipse+maven配置
- Maven下载及配置
- maven 下载安装配置
- Maven下载和配置
- Maven下载及配置
- Maven下载、安装、配置
- maven下载配置
- maven 下载及配置
- Maven下载+配置
- 配置镜像以及从私服下载jar包
- 04 Activity窗口间的切换及参数的传递
- Java中日期和字符串的互相转化
- linux -my ls
- PAT 甲级 1034. Head of a Gang (30)
- react-native学习之路2项目的导入与导出
- 配置Maven从私服下载构件
- jquery获得table当前行中的所有内容
- 蛇形填数
- AndroidUI控件的自定义属性
- python里使用带参数的装饰器
- win7+vs2015+opencv3.1(64位)
- PAT 甲级 1035. Password (20)
- java面试题目03
- Spring分析源码