繁体   English   中英

为什么Maven每次都会先从Maven中央服务器搜索我的私有依赖项jar?

[英]Why does maven search my private dependency jar from maven central server first every time?

我的Maven私人伺服器(连结)中有一个名为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>

如果不检查存储库索引,Maven无法知道您的Maven坐标指向何处。 我建议您在中央Maven存储库和其他存储库中使用您的联系代理,然后在settings.xml中添加一个镜像节

这样,所有请求都将发送到nexus,如果nexus没有工件,它将对其进行缓存并提供服务,以便下次您可以更快地获得它。

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

Nexus书中查看一个示例settings.xml。

暂无
暂无

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

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