且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Maven通过中间pom文件拉取依赖关系

更新时间:2023-01-19 14:58:24

正如你所说,打包为middle_pom pom ,然后只需添加一个依赖关系到这样的mypom.xml:

 <依赖关系> 
< groupId> com.my.group< / groupId>
< artifactId> middle_pom< / artifactId>
< version> 0.1< / version>
< type> pom< / type>
<依赖关系>

虽然如果你解释你想做的这个原因,有人可能会给你一个更有帮助建议。


In Maven is it possible to depend on jar1 and jar2 but establish this dependency via a middle pom file like so:

mypom.xml --> middle_pom.xml --> jar1, jar2

Can this be done in that way?

Of course the packaging for mypom.xml is whatever I want like 'war' but the packaging for middle_pom.xml would be 'pom', agree?

As you say, make the packaging for middle_pom pom, then just add a dependency to mypom.xml like so:

<dependency>
    <groupId>com.my.group</groupId>
    <artifactId>middle_pom</artifactId>
    <version>0.1</version>
    <type>pom</type>
<dependency>

Though if you explain the reason you want to do this someone might be able to give you a more helpful suggestion.