如何在Maven settings.xml中设置存储库的顺序 [英] How to set order of repositories in Maven settings.xml

查看:138
本文介绍了如何在Maven settings.xml中设置存储库的顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在settings.xml中有3个存储库,因为我需要来自所有存储库的工件。每当找不到依赖项时,Maven尝试

I have 3 repositories in my settings.xml because I need artifacts from all of them. Whenever a dependency is not found, Maven tries

Downloading: http://some.server/mvn2repo/releases/org/apache/lucene/lucene-core/2.9.1/...
[INFO] Unable to find resource 'org.apache.lucene:lucene-core:pom:2.9.1' in repository
Downloading: http://some.server/mvn2repo/3rdParty/org/apache/lucene/lucene-core/2.9.1/...
[INFO] Unable to find resource 'org.apache.lucene:lucene-core:pom:2.9.1' in repository
Downloading: http://repo1.maven.org/maven2/org/apache/lucene/lucene-core/2.9.1/lucene-core-2.9.1.pom
<success>

所有存储库,但大多数情况下当然会在中央(repo1)找到工件。我希望Maven先检查这个回购。我在settings.xml中尝试了声明顺序,但是没有用。根据 fgysin ,我也尝试了相反的顺序,它没有改变任何东西。

all repositories, but most of the time finds the artifact in central (repo1) of course. I want Maven to check this repo first. I tried order of declarations in settings.xml, but did not work. According to fgysin I also tried the reverse order, which didn't change anything.

My Maven版本:

My Maven version:

C:\>mvn -v
Apache Maven 2.2.1 (r801777; 2009-08-06 21:16:01+0200)
Java version: 1.6.0_15
Java home: C:\Program Files\Java\jdk1.6.0_15\jre
Default locale: de_AT, platform encoding: Cp1252
OS name: "windows vista" version: "6.0" arch: "amd64" Family: "windows"

我的 settings.xml

<profiles>
    <profile>
        <id>space</id>
        <repositories>
            <repository>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
                <id>s1-releases</id>
                <name>System One Releases</name>
                <url>http://some.server/mvn2repo/releases</url>
            </repository>
            <repository>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
                <id>s1-3rdParty</id>
                <name>System One 3rd Party Releases</name>
                <url>http://some.server/mvn2repo/3rdParty</url>
            </repository>
            <repository>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
                <id>central</id>
                <url>http://repo1.maven.org/maven2</url>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
                <id>central</id>
                <url>http://repo1.maven.org/maven2</url>
            </pluginRepository>
        </pluginRepositories>
    </profile>
</profiles>

<activeProfiles>
    <activeProfile>space</activeProfile>
</activeProfiles>


推荐答案

据我所知,存储库的顺序在你的pom.xml还将决定存储库访问的顺序。

As far as I know the order of the repositories in you pom.xml will also decide the order of the repository access.

至于在settings.xml中配置repos我已经读过repos的顺序很有趣了如何访问回购的顺序。

As for configuring repos in settings.xml I've read that the order of repos is interestingly enough the inverse order of how the repos will be accessed.

这里有人解释这种好奇心的帖子:

http://community.jboss.org/message/576851

Here a post where someone explains this curiosity:
http://community.jboss.org/message/576851

这篇关于如何在Maven settings.xml中设置存储库的顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆