在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 ...
随机推荐
- Xcode中设置按钮在十分钟之内禁用
btn.enabled=NO;` NSTimer * notificationTimer = [NSTimer scheduledTimerWithTimeInterval:10*60.0 targe ...
- jqeury轮播
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...
- javascript学习(二) DOM操作HTML
一:DOM操作HTML JavaScript能够改变页面中所有的HTML元素 JavaScript能够改变页面中所有的HTML属性 JavaScript能够改变页面中所有的CSS样式 JavaScri ...
- EasyUI扩展方法
EasyUI扩展方法: 1.我想指定textarea的行,但editor:{type:'textarea', options: {rows:'4'}}这样写不行.请问大家怎么配置才是指定行的啊? 配置 ...
- 30个实例详解TOP命令
Linux中的top命令显示系统上正在运行的进程.它是系统管理员最重要的工具之一.被广泛用于监视服务器的负载.在本篇中,我们会探索top命令的细节. AD: Linux中的top命令显示系统上正在运行 ...
- ContentProvider官方教程(6)provider支持的数据类型
Provider Data Types Content providers can offer many different data types. The User Dictionary Provi ...
- 分享:扩展Visual Studio 的简单方法
作为 MS 阵营的码农,相信Visual Studio 肯定是大家的主要武器了,但不知道大家有没有扩展Visual Studio 的需求. 最近我需要做一个工具,发现最好是实现在VS里面,于是,Goo ...
- 高通平台 lcd driver 调试小结
一.概述 1.1 简介 本文档主要包括LCD模块的驱动流程分析.Framebuffer相关知识.Gralloc等相关内容,以及LCD调试的一些经验和相关bug的分析和讲解. 1.2 开发环境 And ...
- iOS日常工作之常用宏定义大全
前言: 在工作中, 很多小伙伴都会在PCH文件定义一些常用的宏,但是又怕写这些简单的宏浪费时间,又有时候忘记怎么定义了怎么办?本人在工作中也是如此.所以在这里给大家分享一些常用的宏定义,喜欢的小伙伴可 ...
- Apply Root Motion
Apply Root Motion 应用根动作: Should we control the character's position from the animation itself or fro ...