Maven私服软件Nexus

Nexus私服是一个衍生的特殊的Maven仓库。

一、作用

1.它可以代理外部公共库(如Maven核心库、第三方依赖构件)。

通过建立内部的私服,可以高效的使用Maven,降低对中央仓库的访问负荷。

由于在公司内网可以直接快速的访问私服,降低外网带宽、不稳定对依赖的jar、插件的Maven构建过程影响。

2.自定义部署构件至Nexus私服。

增加Maven项目的灵活性,对于无法从公共仓库中获得的第三方构件,以及项目各个团队间均需要使用的自定义公共构件可以部署至Nexus私服。

二、前面说Nexus是一个特殊的Maven仓库,Nexus把其中的仓库分为三种:

1.宿主仓库。

主要用于存放项目部署的构建,或者第三方构件用于提供下载。

2.代理仓库。

提供下载缓存构件和插件(如从远程中央仓库下载构件和插件)。

3.仓库组。

使用仓库组是为了减轻每个仓库的Maven配置而引入的,它没有实际内容。当须要下载构件时,它会转向其宿主仓库或代理仓库。

3个仓库之间的关系如下(参考自:<<Maven 实战>>)


三、下载与部署

1.Maven从Nexus中下载构件:(profile机制配置Setting.xml)

2.Maven部署构件至Nexus:(distributionManagement机制配置Setting.xml,此情况需要同时配置Servers认证信息)

注:以上两种情况如果仅是在POM.xml中进行配置的话,仅对当前项目有效。在Setting.xml中配置对本机所有项目有效。

例如:

在Setting.xml中配置Nexus仓库(profile机制):

<setting>
...
  <profiles>
    <profile>
     <id>hello_nexus</id>
     <repositories>
      <repository>
       <id>hello_nexus</id>
       <name>hello_nexus</name>
       <url>http://localhost:8081/nexus/content/groups/public</url>
      </repository>
     </repositories>
   </profile>
在Setting.xml中配置Maven部署构件至Nexus(distributionManagement机制):

<project>
...
 <distributionManagerment>
  <repository>
   <id>hello_nexus_release</id>
   <name>hello nexus relese</name>
   <url>http://localhost:8081/nexus/content/repositories/release</url>
  </repository>
 </repositories>
.....
 <settings>
...
  <servers>
    <server>
    <id>hello_nexus_release</id>
    <username>admin</username>
    <password>******</password>
    </server>
  </servers>
</settings>
同时我们还可以通过手动的方式来进行下载或部署。








  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值