1. Artifactory 初始用户名密码为 admin/password
2. 指定一个Internet端资源库
点击左边Configuration导航栏 -> Repositories,选择右边Admin页签,Remote Repositories下可以创建(New)一个Internet端资源库。
具体应用:如我们现在要用到3.0.0.RC3 版本的Spring的jar包,当然这些jar包在 http://repo1.maven.org/maven2 及maven的官方资源库上是找不到的,所以我们需要指定一个包含Spring 3.0.0.RC3 版本jar包的资源库,可以为 http://maven.springframework.org/milestone,网址来源 。
3. 配置Maven2 的 setting.xml,将本地maven的repository的源头指向私服(由 Artifactory 创建)
<profiles>
<profile>
...
<repositories>
<repository>
<id>central</id>
<url>http://localhost:8081/artifactory/repo</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>snapshots</id>
<url>http://localhost:8081/artifactory/repo</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://localhost:8081/artifactory/plugins-releases</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>snapshots</id>
<url>http://localhost:8081/artifactory/plugins-snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
...
</profile>
</profiles>
运行mvn commands,就会到私服上去请求相应的jar包和plugins,如果私服上有对应的jar包或plugins,则直接从私服上获得,如果私服上目前还没有,则由私服从远端资源库(Remote Repository)下载相应的jars和plugins到私服上,再让请求客户端从私服上获得先前请求的jars或plugins。
本文介绍如何配置Artifactory作为Maven的仓库,并设置远程仓库获取特定版本的依赖,如Spring 3.0.0.RC3的jar包。通过修改Maven的setting.xml文件,实现从私服获取依赖,若私服中没有则自动从远程仓库拉取。
779

被折叠的 条评论
为什么被折叠?



