快速业务通道

初学maven(3)-使用nexus替代artifactory作为maven私服 - 编程入门网

作者 佚名技术 来源 NET编程 浏览 发布时间 2012-06-16
lt;enabled>true</enabled></releases>        <snapshots><enabled>false</enabled></snapshots>      </pluginRepository>      <pluginRepository>        <id>nexus</id>        <name>localprivatenexus</name>        <url>http://localhost:8081/nexus/content/groups/public-snapshots</url>        <releases><enabled>false</enabled></releases>        <snapshots><enabled>true</enabled></snapshots>      </pluginRepository>     </pluginRepositories>    </profile>

修改activeProfiles为:

<activeProfiles>      <activeProfile>nexus</activeProfile>     </activeProfiles>

5. 为nexus增加Artifact

有些特殊的Artifact无法从maven官网仓库中下载,比如sun的一些包,只好自己自行下载后添加到私服中。

在nexus中我选择将这些Artifact上传到默认安装就存在的仓库3rd Party中,右击仓库名,选择Upload Artifact。

初学maven(3)-使用nexus替代artifactory作为maven私服(3)

时间:2011-06-27 BlogJava aoxj

6. 在eclipse中使用索引功能

原来试过,使用artifactory私服也可以使用Artifact的索引功能,但是由于不知道怎么设置远程仓库的index,我只会设置

当前artifactory私服已有的Artifact的索引,对于还没有导入到artifactory私服的Artifact就没有办法索引了,很不方便,

毕竟刚开始使用maven时,所有用到的Artifact都是本地和私服没有而需要到远程仓库取的。

nexus中可以很方便的得到远程仓库的Artifact的索引,在上面“3. 配置nexus”就介绍过。下面介绍如何在eclispe里面

设置和使用索引功能:

1) 打开Maven Indexes 的eclispe view

在eclispe中选择window -> show view -> other ... -> Maven -> Maven Indexes

2) 添加nexus的index

右键菜单中选"add index", 在弹出的"Add Respository index"窗口中填入:

Repository URL: http://localhost:8081/nexus/content/groups/public        Repository Id: nexus

Index Update URL: 放空,暂时还不知道该怎么填

加入后eclispe会自动load一次index信息,然后就可以在新加入的index下可以拉出极大数量的Artifact信息。

3) 测试一下使用

找个pom.xml文件,右键 -> Add Dependency, 然后填入一个关键词,比如我填入mina,马上填出和mina相关的一些

选择,我找到apache mina,双击最新一个版本。会自动在pom.xml文件中增加以下内容:

<dependency>        <groupId>org.apache.directory.mina</groupId>        <artifactId>mina-core</artifactId>        <version>0.9.5</version>      </dependency>

然后Maven自动下载jar包,再将jar包加入项目的build path,全程自动化处理,真是爽啊。

初学maven(3)-使用nexus替代artifactory作为maven私服(4)

时间:2011-06-27 BlogJava aoxj

7. 为nexus增加新的proxy repository

方法很简单,administration -> Repositories -> add -> proxy,填写后保存即可。但是要注意,nexus不会自动将新加入的repository添加到group中,而我们一般喜欢直接使用默认的"public repository" group, 比如前面我在maven的profile中就只设置了这一个URL: http://localhost:8081/nexus/content/groups/

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号