首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Artifactory中的依赖项解析配置

Artifactory中的依赖项解析配置
EN

Stack Overflow用户
提问于 2012-11-14 21:30:24
回答 2查看 10K关注 0票数 12

最近,我们开始与Artifactory合作。我们按照Artifactory的建议配置了settings.xml。然而,在运行"mvn compile“时,我们在下载jars时遇到了问题,即使它们出现在Artifactory repo中。显式添加repo1-cache解决了编译问题,但下载是从远程存储库执行的,而不是从Artifactory。

代码语言:javascript
复制
<repository>
    <id>My Repository</id>
    <name>MyRepository-releases</name>
    <url>http://mvn-srv:8081/artifactory/repo1</url>
</repository>

应该向中的settings.xml添加什么,以便自动解析依赖关系并从artifactory中获取它们,而不是每次都访问远程服务器?

settings.xml:

代码语言:javascript
复制
<?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>

编译错误:

代码语言:javascript
复制
[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]
EN

回答 2

Stack Overflow用户

发布于 2012-11-14 22:52:05

除了@duncan-jones优秀的答案之外,解决问题的好方法是执行Trace Artifact Retrieval call,在您的情况下:

代码语言:javascript
复制
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版本。

票数 8
EN

Stack Overflow用户

发布于 2012-11-14 22:10:00

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

例如,libs-release通常会同时映射到内部和外部发布存储库。也许这是错误的配置,导致它没有命中您想要的存储库。

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

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

也许这些虚拟存储库中有一个缺少repo1

票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13379754

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档