maven 新手求救,如何正确利用 maven 私服 nexus 中的多个 repo?

2019-11-08 13:12:53 +08:00
 leiuu

有一个困惑 ,Nexus Repository Manager 配置了多个 repo ( repository ) ,每一个对应了不同的路径。

项目构建中的 jar 包可能依赖其中多个 repo,该如何配置 settings.xml ,使得项目构建过程中会自动搜索 nexus 上的所有 repo。

Nexus 界面截图:

可以看到其中有多个 repo,每个 repo 的 repo path 不一致。

例如,现在做了如下配置:

 <profiles>
        <profile>
            <id>nexus</id>
            <repositories>
                <repository>
                    <id>nexus</id>
                    <url>http://10.11.110.42:8081/nexus/content/groups/public/</url>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                </repository>
            </repositories>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>nexus</activeProfile>
    </activeProfiles>


项目构建时只能从这个 /nexus/content/groups/public/ 路径下搜索 jar,而部分需要的 jar 包在 nexus 的其他路径下,这时该怎么处理。

1317 次点击
所在节点    程序员
6 条回复
Aruforce
2019-11-08 13:18:56 +08:00
在 nexus 上把所有的 repo 都加到 public 那个 group 里;

然后在 setting.xml 里面使用 public group 做 Mirror, mirrorof *

然后 OK....
lc7029
2019-11-08 13:43:51 +08:00
你把所有的 repo 加入到一个组,然后引用这个组就好了
leiuu
2019-11-08 13:49:44 +08:00
@Aruforce
@lc7029
感谢,这样发布代码的时候会有问题吗
不同 type 的 repo,如: group hosted proxy 也可以加到一组中吗
yinzhili
2019-11-08 14:47:58 +08:00
分组就可以了
leiuu
2019-11-08 16:03:00 +08:00
@yinzhili 发现全部的 repo 已经在 public 组里了,更正了一下配置,已经可以下载了,不过特别慢(可能依赖的 jar 比较多)。
szq8014
2019-11-08 17:13:36 +08:00
仓库有类型的,有 proxy/hosted/group
public 那个就是一个组,里面可以配置多个 proxy 或 hosted.
你建一个 hosted 用于上传私有 jar 包,都加进 public 里面就可以统一通过 public 来访问了。


结贴,散花

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/617564

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX