我可以在同一POM中解析来自一个repo的一个Maven依赖项和来自第二个repo的另一个依赖项吗?

我可以在同一POM中解析来自一个repo的一个Maven依赖项和来自第二个repo的另一个依赖项吗?,maven,repository,dependency-management,Maven,Repository,Dependency Management,我们有一个具有多个父/子POM的项目。所有POM都指向一个用于解决所有Maven依赖关系的存储库 现在我有一个需求:在一个POM中,必须从repo1下载一个jar,从repo2下载其余4-5个jar 你怎么能做到这一点呢?一句话——是的。Maven的依赖项解析机制完全独立于存储库机制。从理论上讲,您可以从自己的存储库中交付每一个jar(无论这样做多么荒谬)。据我所知, 我可以在artifactory/nexus中设置maven repo 例如http://localhost:18081/arti

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

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


你怎么能做到这一点呢?

一句话——是的。Maven的依赖项解析机制完全独立于存储库机制。从理论上讲,您可以从自己的存储库中交付每一个jar(无论这样做多么荒谬)。

据我所知,
我可以在artifactory/nexus中设置maven repo
例如http://localhost:18081/artifactory/ -->L1
1.在artifactory中创建远程(R1)存储库,它可以将URL指向外部存储库,由artifactory/nexus托管
例如http://remotehost:18081/artifactory/remote-报告1
2.在我的工件库中创建一个“虚拟”存储库(V1),并将远程(R1)添加到此V1中。
3.让我的所有POM指向我的本地artifactory虚拟存储库(V1),
e、 g.>http://localhost:18081/artifactory/virtual
这样,maven就会看到
A.本地.m2文件夹
B然后在我的人工制品的虚拟回购中寻找罐子
因此,虚拟将看起来
b1。所有本地回购协议
b2。所有远程缓存repo
b3。所有远程回购-->例如。http://remotehost:18081/artifactory/remote-报告1
我正在尝试,一旦成功,我会更新
编辑:

这对我很有效,我唯一遇到的问题就是我的~/.m2/settings.xml 快照为false,远程repo中的my jar是快照jar。 将此值更改为true后,现在将获取jar:) 虚拟回购 中心的 **真的**
pom从不指向存储库。pom声明存储库(这是一种糟糕的做法)。您应该使用存储库管理器来处理这个问题。在POM中,通常根本不应该定义任何存储库。仅在settings.xml中定义存储库,或者最好只定义一个组,用于解决由存储库管理器(如Neuxs)在后台处理的依赖关系。@khmarbaise如果这是一个错误的做法,为什么会说:“下载和部署的存储库已定义[sic!未声明?;]通过POM的
存储库
分发管理
元素?而且,我知道,声明是POM的官方措辞(由于它们的声明性质),但是为什么你认为指向是那么糟糕呢?你能分享一下标签吗?因为我无法在pom文件中的标记中看到任何与repo url相关的标记,这对我来说很有效,所以我唯一遇到的问题是我的~/.m2/settings.xml
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>