`
- 浏览:
264396 次
- 性别:
- 来自:
北京
-
使用nexus替代artifactory作为maven私服
1. 首先下载Nexus
从官网http://nexus.sonatype.org/download.html下载下载最新版本,因为是在windows上安装,因此下载的是zip版本,大小大概是16m。
2. 安装
简单解压缩下载的zip包到安装目录就可以了。
可执行文件在%nexus安装目录%\nexus-webapp-1.0.0\binjsw\windows-x86-32下:
InstallNexus.bat/UninstallNexus.bat是安装/卸载nexus为windows service,如果需要设置nexus为开机自动启动就可以安装为windows service然后设置启动方式为自动。
Nexus.bat是直接在命令行中启动Nexus,如果不想安装Nexus为windows service,可以用这个文件来手工控制Nexus的启动退出。
3. 配置nexus
首先登录,默认地址http://localhost:8081/nexus/,默认用户名密码为admin/admin123.
最重要的一件事情就是开启远程索引下载,索引这个功能实在是太好用了。
nexus默认是关闭远程索引下载功能的,主要是担心会造成对服务器的巨大负担,需要我们手工开启。
开启的方式:
点击Administration菜单下面的Repositories,将这三个仓库Apache Snapshots,Codehaus Snapshots,Maven Central的Download Remote Indexes修改为true。然后在这三个仓库上分别右键,选择Re-index,这样Nexus就会去下载远程的索引文件。
4. 配置maven
要让maven使用nexus作为私服,需要做一些设置,使用和原来设置artifactory相似的方法。修改~/.m2/settings.xml.
增加nexus的profile:
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>nexus</id>
<name>local private nexus</name>
<url>http://localhost:8081/nexus/content/groups/public</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
<repository>
<id>nexus</id>
<name>local private nexus</name>
<url>http://localhost:8081/nexus/content/groups/public-snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>local private nexus</name>
<url>http://localhost:8081/nexus/content/groups/public</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</pluginRepository>
<pluginRepository>
<id>nexus</id>
<name>local private nexus</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。
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,全程自动化处理,真是爽啊。
7. 为nexus增加新的proxy repository
方法很简单,administration -> Repositories -> add -> proxy,填写后保存即可。但是要注意,nexus不会自动将新加入的repository添加到group中,而我们一般喜欢直接使用默认的"public repository" group, 比如前面我在maven的profile中就只设置了这一个URL: http://localhost:8081/nexus/content/groups/public。因此需要手工修改"public repository" group的设置,将刚才添加的proxy repository加到组中。
推荐的repository有:
1) jboss http://repository.jboss.com/maven2/
2) sun http://download.java.net/maven/2/
3)k-int http://developer.k-int.com/maven2/
加入这个纯粹是因为它有sun的jmxri/jmxtools这些Artifact,强烈鄙视sun,自己的官方repository居然没有。
8. 总结
很明显,nexus无论是在界面,功能,操作上,都比artifactory强大的多。
因此推荐大家使用nexus替代artifactory作为maven私服。
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
使用nexus替代artifactory作为maven私服
使用Artifactory设置Maven2组件库
该工具旨在简化从 Sonatype Nexus 到 JFrog Artifactory 的过渡。 它提供了一个简单的类似向导的界面,允许您轻松配置和运行从 Nexus 实例到 Artifactory 实例的存储库、工件、用户和设置的迁移。 目前,可以迁移...
下载Word版 博文链接:https://forearrow.iteye.com/blog/171385
Nexus是Sonatype推出的强大Maven仓库管理器产品,要比以前TSS上介绍的Artifactory要好使用的多,也是一个拆箱即用的Java App,内嵌Jetty容器和Java Wrapper做Windows服务,安装简单到解压然后双击install即可。...
设置Maven仓库-Artifactory
1、 安装好私服,使用nexus或artifactory 2、 配置maven conf/setting.xml文件 添加上传验证 <id>release <username>admin <password>admin123 <id>snapshot <username>admin <password>admin123 ...
该插件解析Maven存储库的maven-metadata.xml而不是使用Nexus API,因此可以用于更广泛的Artifactory和Nexus存储库。 GoCD JSON API的使用 在以下存储库上进行了测试: Maven中央() JBoss Nexus() Bintray ...
仓库:对maven来说仓库分为两类:本地仓库和远程仓库,远程仓库又分为中央仓库 私服和...有三种专门的Maven仓库管理软件可以用来帮助我们建立私服:chiva、Artifactory和Nexus。Nexus是当前最流行的Maven仓库管理软件。
Artifactory REST Example Artifactory REST Example 使用java rest api访问 artifactory
SAMPLE_MAVEN_ARTIFACTORY
使用Artifactory上传library至本地maven仓库示例项目,原文地址:http://blog.csdn.net/level_26/article/details/53483444
webapp-examples 使用 Artifactory 作为后端的 Web 应用程序示例
Artifactory REST Example 使用java rest api访问 artifactory
支持上传多种maven仓库,配置相关全部自动生成,无需在项目中增加上传配置,支持使用maven、artifactory插件swing界面上传
使用作为npm模块数据存储的代理服务器。 将节点无缝集成到基于Java / Maven的工作流程中很有用。 。 将npmjs.org上的网络压力减轻到内部工件 发布和使用您的专有模块,而没有主要的解决方法 快照/收缩您的依赖项...
资源来自pypi官网。 资源全名:artifactory-0.1.6.tar.gz