迷彩 潜伏 隐蔽 伪装
分类:
2012-12-10 10:43:10
原文地址:用artifactory搭建maven2内部服务器 作者:soakcpp
参考 http://forearrow.iteye.com/blog/171385
访问
下载最新的zip包(内置jetty)
<以下操作在ubuntu 8下执行>
编辑当前用户~/.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
想做的更漂亮点,可以把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
BalancerMember ajp://127.0.0.1:8011
这样就可以用
的地址去访问了
要使maven客户端从刚刚创建的maven服务器下载,需要在C:/Documents and Settings/Administrator/.m2下添加settings.xml文件,编辑其内容如下:
另外,由于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