最近我们开始使用Artifactory。我们将settings.xml配置为Artifactory建议。但是,在运行“mvn compile”时我们在下载jar时遇到问题,即使它们出现在Artifactory repo中。显式添加repo1-cache解决了编译问题,但是从远程存储库而不是Artifactory执行下载。
<repository>
<id>My Repository</id>
<name>MyRepository-releases</name>
<url>http://mvn-srv:8081/artifactory/repo1</url>
</repository>
应该在settings.xml中添加什么来自动解决依赖关系并从工件中获取它们而不是每次访问远程服务器?
<?xml version="1.0" encoding="UTF-8"?>
<settings
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"
xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>http://mvn-srv:8081/artifactory/libs-release</url>
</repository>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>snapshots</id>
<name>libs-snapshot</name>
<url>http://mvn-srv:8081/artifactory/libs-snapshot</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>http://mvn-srv:8081/artifactory/plugins-release</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>http://mvn-srv:8081/artifactory/plugins-snapshot</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
<servers>
<server>
<id>MyRepository</id>
</server>
</servers>
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 14.355s
[INFO] Finished at: Wed Nov 14 14:52:31 IST 2012
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project common: Could not resolve dependencies for project com.myc
ompany.app:common:jar:1.0-SNAPSHOT: The following artifacts could not be resolved: commons-jxpath:co
mmons-jxpath:jar:1.3-osgi, xpp3:xpp3_min:jar:1.1.3.4.O-osgi, net.java.dev.stax-utils:stax-utils:jar:
20080702-osgi, net.sf.saxon:saxon:jar:8.9.0.4-osgi, net.sf.saxon:saxon-dom:jar:8.9.0.4-osgi, net.sf.
saxon:saxon-xqj:jar:8.9.0.4, dom4j:dom4j:jar:1.6.1-osgi, mx4j:mx4j-jmx:jar:2.1.1-osgi, mx4j:mx4j-imp
l:jar:2.1.1-osgi, mx4j:mx4j-tools:jar:2.1.1-osgi, mx4j:mx4j-remote:jar:2.1.1-osgi, com.yourkit:yjp-c
ontroller-api-redist:jar:9.0.8, org.apache.geronimo.specs:geronimo-jms_1.1_spec:jar:1.1-osgi, common
s-codec:commons-codec:jar:1.3-osgi, commons-httpclient:commons-httpclient:jar:3.1-osgi, quartz:quart
z-all:jar:1.6.6: Could not find artifact commons-jxpath:commons-jxpath:jar:1.3-osgi in central (http
://mvn-srv:8081/artifactory/libs-release) -> [Help 1]
答案 0 :(得分:8)
添加到@ duncan-jones出色的答案,解决问题的好方法是执行Trace Artifact Retrieval调用,在您的情况下:
http://mvn-srv:8081/artifactory/libs-release/commons-jxpath/commons-jxpath/1.3-osgi/commons-jxpath-1.3-osgi.jar?trace
顺便说一下,我甚至没有在repo1中看到1.3-osgi版本。
答案 1 :(得分:7)
您需要确保虚拟存储库映射到您期望的真实存储库。
例如,libs-release
通常会映射到内部和外部版本库。也许这是错误配置的,导致它没有达到你想要的存储库。
在Artifactory中,转到管理员页面,然后查看配置&gt;存储库。在页面底部,查看您的虚拟存储库。双击它们将显示包含的内容。
对我而言,libs-release
包括libs-release-local
,ext-release-local
和remote-repos
。后者是另一个虚拟存储库,它映射到我的安装中列出的所有外部存储库,例如codehaus,repo1,jboss,google-code,...
这些虚拟存储库中的一个可能缺少repo1
?