1

我的 Maven 私有服务器(nexus)中有一个名为 brandstore-repository 的 jar,

为什么maven每次都先从maven中心服务器搜索它?

[artifact:mvn] Downloading: http://search.maven.org/remotecontent?filepath=/com/jumbo/brandstore/brandstore-repository/4.0.0/brandstore-repository-4.0.0.pom
[artifact:mvn] Downloading: http://repository.jboss.com/maven2/com/jumbo/brandstore/brandstore-repository/4.0.0/brandstore-repository-4.0.0.pom
[artifact:mvn] Downloading: https://oss.sonatype.org/content/repositories/snapshots//com/jumbo/brandstore/brandstore-repository/4.0.0/brandstore-repository-4.0.0.pom
[artifact:mvn] Downloading: http://10.8.12.100/nexus/content/groups/public/com/jumbo/brandstore/brandstore-repository/4.0.0/brandstore-repository-4.0.0.pom
[artifact:mvn] 1K downloaded
[artifact:mvn] Downloading: http://search.maven.org/remotecontent?filepath=/com/jumbo/brandstore/brandstore/4.0.0/brandstore-4.0.0.pom
[artifact:mvn] Downloading: http://repository.jboss.com/maven2/com/jumbo/brandstore/brandstore/4.0.0/brandstore-4.0.0.pom
[artifact:mvn] Downloading: https://oss.sonatype.org/content/repositories/snapshots//com/jumbo/brandstore/brandstore/4.0.0/brandstore-4.0.0.pom
[artifact:mvn] Downloading: http://10.8.12.100/nexus/content/groups/public/com/jumbo/brandstore/brandstore/4.0.0/brandstore-4.0.0.pom
[artifact:mvn] 17K downloaded
[artifact:mvn] Downloading: http://search.maven.org/remotecontent?filepath=/com/jumbo/brandstore/brandstore-repository/4.0.0/brandstore-repository-4.0.0.jar
[artifact:mvn] Downloading: http://repository.jboss.com/maven2/com/jumbo/brandstore/brandstore-repository/4.0.0/brandstore-repository-4.0.0.jar
[artifact:mvn] Downloading: https://oss.sonatype.org/content/repositories/snapshots//com/jumbo/brandstore/brandstore-repository/4.0.0/brandstore-repository-4.0.0.jar
[artifact:mvn] Downloading: http://10.8.12.100/nexus/content/groups/public/com/jumbo/brandstore/brandstore-repository/4.0.0/brandstore-repository-4.0.0.jar
[artifact:mvn] 913K downloaded

在我的 setting.xml 文件中,我已经在顶部设置了我的私人服务器(nexus)“http://10.8.12.100/nexus/content/groups/public”

和 activeProfiles 我在“maven-home”之前设置了“profile-baozun”

<profiles>
        <profile>
            <id>profile-baozun</id>
            <repositories>
                <repository>
                    <id>public</id>
                    <url>http://10.8.12.100/nexus/content/groups/public</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </repository>

                <repository>
                    <id>loxia2</id>
                    <url>http://loxia2.googlecode.com/svn/repository</url>
                    <releases>
                        <enabled>true</enabled>
                        <checksumPolicy>warn</checksumPolicy>
                    </releases>
                </repository>
            </repositories>
        </profile> 

        <profile>
            <id>maven-home</id>
            <repositories>
                <repository>
                    <id>central</id>
                    <url>http://search.maven.org/remotecontent?filepath=</url>
                </repository>

                <repository>
                    <id>jboss</id>
                    <url>http://repository.jboss.com/maven2</url>
                </repository>

                <repository>
                    <id>sonatype</id>
                    <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
                </repository>
            </repositories>
        </profile>
    </profiles>

    <activeProfiles>
        <activeProfile>maven-home</activeProfile>
                 <activeProfile>profile-baozun</activeProfile>

    </activeProfiles>
4

2 回答 2

7

如果不检查存储库索引,Maven 无法知道您的 Maven 坐标指向的位置。我建议您将您的 nexus 代理放在中央 maven 存储库和其他存储库中,然后在 settings.xml 中添加一个镜像节。

这样所有的请求都会去nexus,如果nexus没有工件,它会缓存它并提供它,这样下一次,你会更快地得到它。

于 2012-11-27T09:39:32.450 回答
1

我建议将 settings.xml 设置为仅指向存储库组,然后将其他代理和托管存储库添加到 Nexus 中的组。这样您就不必在第一次安装后重新配置 settings.xml。

查看Nexus book中的示例 settings.xml 。

于 2012-12-03T04:30:36.247 回答