在Maven中设置Nexus私有服务为中央工厂(repository)
原文:http://blog.csdn.net/mexican_jacky/article/details/50275695
nexus中的仓库列表
第一种方式:
<repositories>
<repository>
<id>nexus</id>
<name>nexus Repository</name>
<url>http://localhost:8081/nexus/content/repositories/central/</url>
</repository>
</repositories>
这种方式,Maven仅仅只会在nexus中的central中央工厂进行下载,而我们希望我们开发的releases、snapshots工厂都能下载
而这种方式会增加配置的复杂度,并且增加了配置文件的冗余,而没增加一个都会去添加,这种方式不推荐使用
第二种方式:
为解决第一种方式,在nexus中提供了另外一种方式仓库为:Public Repositories 类型为group Repository Path为:http://localhost:8081/nexus/content/groups/public/
的方式
在pom.xml中我们只需要将url地址更改成它的地址即可,用了这个工厂就相当于用了Releases、Snapshots、3rd party 、Central这几个工厂
<repositories>
<repository>
<id>nexus</id>
<name>nexus Repository</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
</repository>
</repositories>
设置了之后,当我们有新的依赖,它就回去nexus中的仓库中去下载
第二种方式,当还一个模块的时候还的配置,这样就不太方便,在企业开发中,我们需要设置一个共有的,因此第三中方式就来了
第三种方式
将自己设置的工厂中的settings.xml进行配置
<profiles>
<profile>
<id>nexusRepository</id>
<repositories>
<repository>
<id>nexus</id>
<name>nexus is Repository</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<!-- 默认就是true -->
<releases>
<enabled>true</enabled>
</releases>
<!-- 默认是是false,需手动打开 设置为true -->
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<!-- 这里必须激活profile 才能生效 -->
<activeProfiles>
<activeProfile>nexusRepository</activeProfile>
</activeProfiles>
这样默认也是从nexus repository下载
第三种方式在nexus服务器停止的了,maven有会从maven的中央工厂mvnrepository进行下载,这是因为,Maven项目首先回去nexus中去找,当它发现nexus服务停止这个时候它就回去找Maven的工厂
在Maven的安装包中的lib中的maven-model-builder-3.3.9.jar中的pom.xml,起配置如下
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
问题就是当我们发现Nexus服务停止了就不能下载,而只能从Nexus中下载,不允许去Maven中下载这就需要第四种方式
第四种方式:配置镜像
配置如下
<mirrors>
<mirror>
<id>mirrorNexusId</id>
<!-- *号代表所有工厂镜像 ,当Maven进来之后,不管什么工厂都回去找URL的地址去下载 -->
<mirrorOf>*</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
</mirror>
</mirrors>
<!-- 这里的工厂配置,是Maven中的,起snapshots是false,我们可以通过这种方式将其激活,就可以访问中央工厂中snapshots -->
<profiles>
<profile>
<id>nexusRepository</id>
<repositories>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<!-- 这里必须激活profile 才能生效 -->
<activeProfiles>
<activeProfile>nexusRepository</activeProfile>
</activeProfiles>
第四种方式就是我们推荐的一种方式
在Maven中设置Nexus私有服务为中央工厂(repository)的更多相关文章
- 在Maven中设置Nexus私有服务为中央工厂
在Maven中设置Nexus私有服务为中央工厂(repository) 2015-12-12 17:45 168人阅读 评论(0) 收藏 举报 分类: Maven(17) 版权声明:本文为博主原创 ...
- Linux中设置服务自启动的三种方式
有时候我们需要Linux系统在开机的时候自动加载某些脚本或系统服务 主要用三种方式进行这一操作: ln -s 在/etc/rc.d/rc*.d目录中建立/e ...
- [转]Linux中设置服务自启动的三种方式
from:http://www.cnblogs.com/nerxious/archive/2013/01/18/2866548.html 有时候我们需要Linux系统在开机的时候自动加载某些脚本或系统 ...
- (转)Linux中设置服务自启动的三种方式
有时候我们需要Linux系统在开机的时候自动加载某些脚本或系统服务 主要用三种方式进行这一操作: ln -s 在/etc/rc.d/rc*.d目录中建立/e ...
- 【转发】Linux中设置服务自启动的三种方式
有时候我们需要Linux系统在开机的时候自动加载某些脚本或系统服务 主要用三种方式进行这一操作: ln -s 在/etc/rc.d/rc*.d目录中建立/e ...
- Maven 本地仓库,远程仓库,中央仓库,Nexus私服,镜像 详解
一. 本地仓库 本地仓库是远程仓库的一个缓冲和子集,当你构建Maven项目的时候,首先会从本地仓库查找资源,如果没有,那么Maven会从远程仓库下载到你本地仓库.这样在你下次使用的时候就不需要从远程下 ...
- window Maven私服搭建——nexus
注:本文来源于 <window Maven私服搭建--nexus> Maven私服搭建--nexus 1.下载nexus https://www.sonatype.com/downlo ...
- Nexus 私有仓库搭建与 Maven 集成
Nexus 私有仓库搭建与 Maven 集成 |作者:RexFang |出处:http://www.cnblogs.com/rexfang/ |关于作者:Java 程序员一枚 |版权:本文版权归作者和 ...
- 3.发布Maven项目到nexus中
1.在pom.xml文件中配置需要发布的工厂 如果想把项目发布到nexus中,需要在pom.xml中配置releases和snapshots版本发布的具体repository <distribu ...
随机推荐
- java.lang.IllegalThreadStateException
java.lang.IllegalThreadStateException 今天遇到了这个问题.当时的情景是想要循环实现了runable的类和继承Thread类的两个线程.可是没有注意到,继承自Thr ...
- c#播放器
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- Database
1.Mysql 本地计算机登陆mysql,(DOC界面)mysql -h 127.0.0.1 -u root -p
- poj1222 EXTENDED LIGHTS OUT
设输入矩阵为A,输出矩阵为B,目标矩阵为C(零矩阵). 方便起见,矩阵行列下标均从1开始. 考虑A矩阵元素a(i,j),B矩阵中与其相邻的元素 b(i,j),b(i - 1, j),b(i + 1,j ...
- 设计模式之——单例模式(Singleton)的常见应用场景
单例模式(Singleton)也叫单态模式,是设计模式中最为简单的一种模式,甚至有些模式大师都不称其为模式,称其为一种实现技巧,因为设计模式讲究对象之间的关系的抽象,而单例模式只有自己一个对象,也因此 ...
- JAVA基础知识之练习题——集合
练习一: 创建一个Set集合,保存用户输入的数据 具体代码实现如下面代码中的testSet()方法. 知识点: Set集合的基本特征是元素不允许重复.HashSet不保存元素顺序,LinkedHash ...
- An Easy C Program Problem
找幸运数 题目描述 数字8最多的那个数为幸运数. 输入n和n个整数,找这n个数中的幸运数.在主函数中调用ndigit函数,判断某个整数x含数字8的个数.如果有多个幸运数输出第一个幸运数,如果所有的数中 ...
- nyoj CO-PRIME 莫比乌斯反演
CO-PRIME 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 This problem is so easy! Can you solve it? You are ...
- D3D 模板缓存的创建过程
下面是我对模板缓存创建的理解: 1. 模板缓存是和深度缓存一起被创建的,将深度缓存的一部分作为模板缓存使用. 深度缓存和模板缓存是在Direct3D初始化时创建的,D3DPRESENT_PARAMET ...
- mysql分库分表
1.分库分表 很明显,一个主表(也就是很重要的表,例如用户表)无限制的增长势必严重影响性能,分库与分表是一个很不错的解决途径,也就是性能优化途径,现在的案例是我们有一个1000多万条记录的用户表mem ...