原文: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)的更多相关文章

  1. 在Maven中设置Nexus私有服务为中央工厂

    在Maven中设置Nexus私有服务为中央工厂(repository) 2015-12-12 17:45 168人阅读 评论(0) 收藏 举报  分类: Maven(17)  版权声明:本文为博主原创 ...

  2. Linux中设置服务自启动的三种方式

    有时候我们需要Linux系统在开机的时候自动加载某些脚本或系统服务 主要用三种方式进行这一操作: ln -s                       在/etc/rc.d/rc*.d目录中建立/e ...

  3. [转]Linux中设置服务自启动的三种方式

    from:http://www.cnblogs.com/nerxious/archive/2013/01/18/2866548.html 有时候我们需要Linux系统在开机的时候自动加载某些脚本或系统 ...

  4. (转)Linux中设置服务自启动的三种方式

    有时候我们需要Linux系统在开机的时候自动加载某些脚本或系统服务 主要用三种方式进行这一操作: ln -s                       在/etc/rc.d/rc*.d目录中建立/e ...

  5. 【转发】Linux中设置服务自启动的三种方式

    有时候我们需要Linux系统在开机的时候自动加载某些脚本或系统服务 主要用三种方式进行这一操作: ln -s                       在/etc/rc.d/rc*.d目录中建立/e ...

  6. Maven 本地仓库,远程仓库,中央仓库,Nexus私服,镜像 详解

    一. 本地仓库 本地仓库是远程仓库的一个缓冲和子集,当你构建Maven项目的时候,首先会从本地仓库查找资源,如果没有,那么Maven会从远程仓库下载到你本地仓库.这样在你下次使用的时候就不需要从远程下 ...

  7. window Maven私服搭建——nexus

    注:本文来源于 <window   Maven私服搭建--nexus> Maven私服搭建--nexus 1.下载nexus https://www.sonatype.com/downlo ...

  8. Nexus 私有仓库搭建与 Maven 集成

    Nexus 私有仓库搭建与 Maven 集成 |作者:RexFang |出处:http://www.cnblogs.com/rexfang/ |关于作者:Java 程序员一枚 |版权:本文版权归作者和 ...

  9. 3.发布Maven项目到nexus中

    1.在pom.xml文件中配置需要发布的工厂 如果想把项目发布到nexus中,需要在pom.xml中配置releases和snapshots版本发布的具体repository <distribu ...

随机推荐

  1. pip命令使用国内pypi镜像源加速在线安装

    参考:http://www.cnblogs.com/yudar/p/4444097.html 用easy_install和pip来安装第三方库很方便 它们的原理其实就是从Python的官方源pypi. ...

  2. 使用Keil的MicroLIB时自动设置堆大小——玩嵌入式以来最高难度

    Keil编译项目,如果使用微库MicroLIB,就可以使用malloc.微库内部位置一个堆管理模块.芯片的RAM大小是固定了的,前面分为全局变量,后面分给堆和栈,这是一般开发方式.但是我们在开发项目的 ...

  3. select resharper shortcuts scheme

    VS代码生成工具ReSharper提供了丰富的快捷键,可以极大地提高你的开发效率.安装ReSharper后首次启动Visual Studio时,会出现一个名为ReSharper Keyboard Sc ...

  4. C#中的异步和同步

    同步 同步(英语:Synchronization [ˌsɪŋkrənaɪ'zeɪʃn]),指对在一个系统中所发生的事件(event)之间进行协调,在时间上出现一致性与统一化的现象.说白了就是多个任务一 ...

  5. PHP CURL实现远程下载文件到本地

    <?php //$result=httpcopy('http://www.phpernote.com/image/logo.gif'); echo '<pre>';print_r($ ...

  6. IOS自定义仪表盘

      登录|注册     周海锋 的专栏 Objective-C/Cocos2d/Cocos2d-x/Php/JS       目录视图 摘要视图 订阅 2016软考项目经理实战班    学院周年礼-顶 ...

  7. Android权限安全(2)给基本组件自定义权限(以activity为例)

    给基本组件自定义权限(以activity为例) 1.有访问权限的activity的定义端 1.1定义权限 <permission android:name="com.example.f ...

  8. Java过滤器原理方法

    过滤器可以对资源的请求和相应提供过滤功能,配置在web.xml文件中.过滤器可用来实现以下功能1. 权限过滤2. 登陆和检查验证3. 图像转换4. 数据压缩5. 加密6. 令牌验证7. 触发访问资源的 ...

  9. RC4加密解密算法

    RC4相对是速度快.安全性高的加密算法.在实际应用中,我们可以对安全系数要求高的文本进行多重加密,这样破解就有一定困难了.如下测试给出了先用RC4加密,然后再次用BASE64编码,这样双重锁定,保证数 ...

  10. CodeForces 384A Coder

    Coder Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Statu ...