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

查看:42
本文介绍了如何在 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 首先检查这个 repo.我尝试了 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.

我的 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 FilesJavajdk1.6.0_15jre
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 your pom.xml will also decide the order of the repository access.

至于在 settings.xml 中配置存储库,我读到存储库的顺序与存储库访问方式的相反顺序非常有趣.

As for configuring repositories in settings.xml, I've read that the order of repositories is interestingly enough the inverse order of how the repositories 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天全站免登陆