2015-12-12 17:45 168人阅读 评论(0) 收藏 举报
 分类:
Maven(17) 

版权声明:本文为博主原创文章,未经博主允许不得转载。

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私有服务为中央工厂的更多相关文章

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

    原文:http://blog.csdn.net/mexican_jacky/article/details/50275695 nexus中的仓库列表 第一种方式: <repositories&g ...

  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. window Maven私服搭建——nexus

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

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

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

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

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

  9. Linux中设置服务自启动的三种方式,ln -s 建立启动软连接

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

随机推荐

  1. c语言中struct的初始化

    C++中的struct已经和class一样,可以用构造函数初始化. C语言中的struct怎么初始化呢? typedef struct _TEST_T {        int i;        c ...

  2. JAVA 中进行网络通信时,通信的程序两端要传输的对象,不仅要序列化,而且这个对象所属的类的名字要完全一样,连包的名字都得一样

    如上图项目目录,这是一个简易的QQ,客户端登录的时候要传输用户信息到服务器验证,所以两端都会用到User类的对象,但一开始我在Server端的包名是com.qq.server.common,两端的报名 ...

  3. Jenkins构建项目,JAVA_HOME is not defined correctly

    好久都没有更新了,由于职位调整,开始捣鼓持续集成的东西了.jenkins的基本安装配置网上有很多教程,不用多讲了,就记录下我在使用过程中遇到的一些问题.话说这个jenkins环境以及安装好了有一段时间 ...

  4. Windows 下MySQL zip 安装

    主要步骤: 1.下载解压到安装的文件夹 2.配置环境路径 3.配置my.ini文件,设置程序路径和数据存储路径 4.以管理员身份启动Mysqld install(提示sevice安装成功) 5.启动M ...

  5. electron 学习

    index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset=&quo ...

  6. 【原创】python中文编码问题深入分析(三):python2.7文件读写中文编码问题

    上一篇文章介绍和分析了python2.7中使用print遇到的中文编码问题的原因和解决方案,本篇主要介绍一下python2.7中执行文件读写可能遇到的编码问题. 1.文件读取 假如我们读取一个文件,文 ...

  7. 三维重建面试13X:一些算法试题-今日头条AI-Lab

             被人牵着鼻子走,到了地方还墨明棋妙地吃一顿砖头.今日头条AI-Lab,其实我一直发现,最擅长的还是点云图像处理,且只是点云处理. 一.C++题目   New 与Malloc的区别: ...

  8. day002 计算机基础之 操作系统和编程语言的分类

    &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp今天主要针对计算机基础中的操作系统和编程语言的分类进行了讲解. 操作系统 &nbsp ...

  9. PAT_A1141#PAT Ranking of Institutions

    Source: PAT A1141 PAT Ranking of Institutions (25 分) Description: After each PAT, the PAT Center wil ...

  10. X5内核浏览器,video兼容

    使用vue-video-player在移动端微信内置浏览器打开,点击视频自动全屏问题. 参考官方 API 是 H5 同层浏览器的原因,可通过设置video属性来处理. <video-player ...