访问http://www.jfrog.org/sites/jfrog/index.html
下载最新的zip包(内置jetty)
编辑当前用户~/.bashrc文件
增加一行
export ARTIFACTORY_HOME=/home/mvn/artifactory-artifactory-1.3.0-beta-2
重新登陆
运行$ARTIFACTORY_HOME/bin/artifactory.sh
或者
$ARTIFACTORY_HOME/bin/artifactoryctl start
(作为服务后台运行)均可启动jetty来运行artifactory
http://<YourServer>:8081/aritfactory
想做的更漂亮点,可以把jetty部署到apache2后面,可编辑httpd.conf并添加
LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
LoadModule proxy_ajp_module /usr/lib/apache2/modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module /usr/lib/apache2/modules/mod_proxy_balancer.so
#keeps the original Host Header
ProxyPreserveHost On
#map to cluster
ProxyPass /artifactory balancer://my_cluster/artifactory stickysession=JSESSIONID nofailover=On
<Proxy balancer://my_cluster>
BalancerMember ajp://127.0.0.1:8011
</Proxy>
这样就可以用
http://<YourServer>/aritfactory
的地址去访问了
要使maven客户端从刚刚创建的maven服务器下载,需要在C:/Documents and Settings/Administrator/.m2下添加settings.xml文件,编辑其内容如下:
<settings>
<mirrors>
<mirror>
<id>maven.yourcompany.com</id>
<mirrorOf>central</mirrorOf>
<name>yourcompany's Maven Proxy</name>
<url>http://<YourServer>/artifactory/repo</url>
</mirror>
</mirrors>
</settings>
另外,由于velocity1.5的POM定义有错误,会直接导致artifactory下载velocity-1.5.pom时异常,并最终导致m2客户端从m2内部mirror站点build失败。
在m2客户端运行
mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app
服务端错误如下:
2008-07-28 11:06:01.042::WARN: Nested in javax.servlet.ServletException: java.lang.RuntimeException: Failed to save resource '{repo1:velocity/velocity/1.5/velocity-1.5.pom}'.:
java.lang.RuntimeException: Failed to save resource '{repo1:velocity/velocity/1.5/velocity-1.5.pom}'.
at org.artifactory.repo.JcrRepo.saveResource(JcrRepo.java:418)
......
Caused by: java.lang.RuntimeException: Failed to execute JcrCallback.
at org.artifactory.jcr.JackrabbitJcrWrapper.doInSession(JackrabbitJcrWrapper.java:243)
at org.artifactory.repo.JcrRepo.saveResource(JcrRepo.java:381)
... 38 more
客户端错误如下:
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] org/apache/commons/lang/StringUtils
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.NoClassDefFoundError: org/apache/commons/lang/StringUtils
at org.apache.velocity.runtime.resource.ResourceManagerImpl.initialize(ResourceManagerImpl.java:165)
解决办法:
编辑$ARTIFACTORY_HOME/bin/artifactory.sh
修改
JAVA_OPTIONS="$JAVA_OPTIONS -Djetty.home=$ARTIFACTORY_HOME -Dartifactory.home=$ARTIFACTORY_HOME"
为
JAVA_OPTIONS="$JAVA_OPTIONS -Djetty.home=$ARTIFACTORY_HOME -Dartifactory.home=$ARTIFACTORY_HOME -Dartifactory.maven.suppressPomConsistencyChecks=true"
运行脚本./artifactory.sh重新启动artifactor,并在客户端运行
mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app
等artifactory服务器成功下载了velocity-1.5.pom,即可恢复artifactory正常启动选项,毕竟官方不推荐
-Dartifactory.maven.suppressPomConsistencyChecks=true