首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >我能否解析同一个POM中的一个Maven依赖项和第二个回购中的另一个依赖项?

我能否解析同一个POM中的一个Maven依赖项和第二个回购中的另一个依赖项?
EN

Stack Overflow用户
提问于 2016-07-02 20:50:29
回答 2查看 855关注 0票数 1

我们有一个有多个父母/孩子家长的项目。所有POMs都指向一个用于解决所有Maven依赖关系的存储库。

现在我有一个需求:在一个POM中,必须从repo1下载一个jar,从repo2下载rest 4-5 jar。

你怎么能这么做?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-07-09 05:38:41

代码语言:javascript
运行
复制
What I have understand the, 
I can setup maven repo in artifactory/nexus 
e.g. http://localhost:18081/artifactory/ --> L1

1. create remote(R1) repository in artifactory, which can point URL to outside repository, hosted by artifactory/nexus
e.g http://remotehost:18081/artifactory/remote-repo1

2. create a "virtual" repository(V1) in my artifactory and add remote(R1) in to this V1.
3. Let all my poms points to my local artifactory virtual repository(V1), 
e.g.>http://localhost:18081/artifactory/virtual

 that way, maven will look
a. local .m2 folder
b. then look for jars in virtual repo of my artifactory
hence virtual will look
  b1. all local repo
  b2. all remote cache repo
  b3. all remote repo --> e.g.http://remotehost:18081/artifactory/remote-repo1

I am experimenting this,once succeed, i will update
EDIT :
This has worked for me, the only hiccup I faced was my ~/.m2/settings.xml
the snapshot was false, and my jar in remote repo is a snapshot jar.
After changing this value to true, now its fetching the jars :)
 </profile>
                <profile>
                        <id>virtual-repo</id>
                        <repositories>
                                <repository>
                                        <id>central</id>
                                          <url><repo_url></url>
                                        <snapshots>
                                                **<enabled>true</enabled>**
                                        </snapshots>
                                </repository>
                        </repositories>
票数 0
EN

Stack Overflow用户

发布于 2016-07-02 20:52:59

一句话-是的。Maven的依赖解决机制完全独立于存储库机制。从理论上讲,您可以将每个罐子都从自己的存储库中传递出来(不管实际这样做多么荒谬)。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38164370

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档