在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 ...
随机推荐
- EF查询分页
static List<T> GetPageList(Func<T,bool> whereLambda,Func<T,object> orderLambda,int ...
- Windows手动添加开机启动项
@方法1. 添加程序完整路径到注册表HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run下 或者添加到HKEY_CURREN ...
- 检索 COM 类工厂中 CLSID 为 {} 的组件时失败,原因是出现以下错误: 80070005
检索 COM 类工厂中 CLSID 为 {00024500-0000-0000-C000-000000000046} 的组件时失败,原因是出现以下错误: 80070005.跟踪了一下,结果是将记录导出 ...
- 2016年6月23日 星期四 --出埃及记 Exodus 14:20
2016年6月23日 星期四 --出埃及记 Exodus 14:20 coming between the armies of Egypt and Israel. Throughout the nig ...
- CI 同时上传多个图片
最近,一直在研究ci框架,由于项目的需求,在后台需要做一个功能同时上传两张图片.测试了好久都没有两张图片都没有上传成功,(上传的结果是只能上传第二张图片,但是图片名称是第一个图片的).在这里说一下自己 ...
- 免费PHP WEB环境套件介绍
PHPNOW--Apache + PHP + MySQL(windows) easyphp--Apache + PHP + MySQL+phpmyadmin(windows) xampp(中文站点)- ...
- 在C#中怎么调用带参数的存储过程啊??
1)执行一个没有参数的存储过程的代码如下:SqlConnection conn=new SqlConnection(“connectionString”);SqlDataAdapter da = ne ...
- 如何用linux远程登录windows计算机
大家可能试过用windows远程登录另一个windows pc机,今天大家将会学到如何用 linux远程登录你的windows系统. 首先大家要做到得救是将自己linux和windows操作机的IP地 ...
- Spring 框架 详解 (二)
Spring的入门的程序: 1.1.1 下载Spring的开发包: spring-framework-3.2.0.RELEASE-dist.zip ---Spring开发包 * docs :sprin ...
- 【转载】CMake 简介和 CMake 模板
转载自我的博客: CMake 简介和 CMake 模板 . 如果你用 Linux 操作系统,使用 cmake 会简单很多,可以参考一个很好的教程: CMake 入门实战 | HaHack .如果你用 ...