Maven project version inheritance - do I have to specify the parent version?

10/14 06:32
阅读数 0

问题:

I have two projects: Parent project: A, Sub project: B我有两个项目:父项目:A,子项目:B

A/pom.xml: A/pom.xml:

<groupId>com.dummy.bla</groupId>
<artifactId>parent</artifactId>
<version>0.1-SNAPSHOT</version>
<packaging>pom</packaging>

And in B/pom.xml, I have:在 B/pom.xml 中,我有:

    <parent>
        <groupId>com.dummy.bla</groupId>
        <artifactId>parent</artifactId>
        <version>0.1-SNAPSHOT</version>     
    </parent>

    <groupId>com.dummy.bla.sub</groupId>
    <artifactId>kid</artifactId>

I want B to inherit the version from parent, so the only place in my case I need to put 0.1-SNAPSHOT is A/pom.xml .我希望 B 从父级继承版本,所以在我的情况下,我需要放置0.1-SNAPSHOT的唯一地方是A/pom.xml But if i remove the <version>0.1-SNAPSHOT</version> from B/pom.xml under the parent section, maven complains about the missing version for the parent.但是,如果我从父部分下的B/pom.xml删除<version>0.1-SNAPSHOT</version> ,maven 会抱怨缺少父版本。

Is there a way I can just use ${project.version} or something like this to avoid having 01.-SNAPSHOT in both poms?有没有办法我可以只使用${project.version}或类似的东西来避免在两个 poms 中都有01.-SNAPSHOT


解决方案:

参考一: https://en.stackoom.com/question/iOsI
参考二: https://stackoom.com/question/iOsI
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部