nexus作为maven的私服

来源:互联网 发布:u型耳夹淘宝 编辑:程序博客网 时间:2024/06/08 01:04

使用nexus作为maven的私服

 私服是架设在局域网的一种特殊的远程仓库,目的是代理远程仓库及部署第三方构件。有了私服之后,当 Maven 需要下载构件时,直接请求私服,私服上存在则下载到本地仓库;否则,私服请求外部的远程仓库,将构件下载到私服,再提供给本地仓库下载。

这里写图片描述

Nexus 的仓库分为这么几类:

  • hosted 类型的仓库,内部项目的发布仓库 

  • releases 内部的模块中release模块的发布仓库

  • snapshots 发布内部的SNAPSHOT模块的仓库  

  • 3rd party 第三方依赖的仓库,这个数据通常是由内部人员自行下载之后发布上去 

  • proxy 类型的仓库,从远程中央仓库中寻找数据的仓库

  • group 类型的仓库,组仓库用来方便我们开发人员进行设置的仓库

为所有仓库配置一个镜像仓库,镜像仓库的地址即私服的地址,修改maven中的setting.xml配置文件,如下:

<mirrors>  <mirror>       <id>central</id>       <mirrorOf>*</mirrorOf>       <name>central-mirror</name>       <url>http://10.10.18.14:8081/nexus/content/groups/public/</url>   </mirror></mirrors><profiles>    <profile>    <id>central-repos</id>      <repositories>        <repository>          <id>central</id>          <name>Central</name>          <url>http://central</url>      <releases><enable>true</enable></releases>      <snapshots>        <enabled>true</enabled>     </snapshots>        </repository>      </repositories>    </profile></profiles>