nexus maven工厂配置

nexus上默认有4种的工厂 分别是:group、hosted(面向的是内部的提交)、 proxy、 virtual


当我们执行mvn : deploy 发布的时候,默认都是提交给hosted类型的工厂

hosted 类型的又有3个版本,分别是:Releases Snapshots 3rd party


proxy类型的工厂主要用到了Central这个工厂,主要把中央工厂里面的第三方包下载到这里来。所以这里要配置一个中央工厂地址。

另外两个proxy用来下载Snapshots的包



group 类型是一个整合,因为他可以多个仓库配置在一起,当内部调用的时候,只需要指向这一个group仓库即可:




在项目中引用(这是其中一种配置引用工厂的一种方式)

<repositories>
<repository>
<id>nexus</id>
<name>Nexus Repository</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<!--  snapshots默认是关闭的,需要手动开启-->
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories> 



当然另外一种就是在maven的setting文件中配置(常用),这样所有的项目的配置都用到了这个仓库:

<pre name="code" class="java"><profile>
      <id>nexusProfile</id>
    <repositories>
<repository>
<id>nexus</id>
<name>Nexus Repository</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<!--snapshots默认是关闭的,需要手动开启-->
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
    </profile>

 <!--激活-->
  <activeProfiles>
    <activeProfile>nexusProfile</activeProfile>
  </activeProfiles>


 


工厂镜像:

默认情况下,当我们的私服stop了,我们找jar包的时候,maven会意识到私服挂了,自动切换到中央仓库去找。

但是有时候我们并不希望这样,当私服挂了,我们就不去中央仓库找了,中央仓库只有私服能访问,这样的话我们就得配置镜像。

 <!---工厂的镜像,只要mirrorOf中的工厂要被访问,都会自动来找镜像的url,如果镜像的url访问不到,那就访问不到了-->

  <mirror>
      <id>mirrorId</id>
      <!--<mirrorOf>nexusProfile,central</mirrorOf>-->
 <mirrorOf>*</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://localhost:8081/nexus/content/groups/public/</url>
    </mirror>






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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值