繁体   English   中英

Artifactory中的依赖关系解析配置

[英]Dependency resolution configuration in Artifactory

最近我们开始使用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中以自动解决依赖关系并从工件中获取它们而不是每次访问远程服务器?

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]

添加到@ 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版本。

您需要确保虚拟存储库映射到您期望的真实存储库。

例如, libs-release通常会映射到内部和外部发行版存储库。 也许这是错误配置的,导致它没有达到你想要的存储库。

在Artifactory中,转到Admin页面并查看Configuration> Repositories 在页面底部,查看您的虚拟存储库。 双击它们将显示包含的内容。

对我来说, libs-release包括libs-release-localext-release-localremote-repos 后者是另一个虚拟存储库,映射到我的安装中列出的所有外部存储库,例如codehaus,repo1,jboss,google-code,...

也许其中一个虚拟存储库缺少repo1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM