nexus maven工厂配置

来源:互联网 发布:阿里云个人免费邮箱 编辑:程序博客网 时间:2024/06/06 02:24

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