gpt4 book ai didi

maven-2 - Maven2继承

转载 作者:行者123 更新时间:2023-12-03 01:13:10 24 4
gpt4 key购买 nike

如果我有一个父pom并且想将其继承到多个项目。我通常通过在项目顶部添加 <parent> ... </parent> 来做到这一点。我不喜欢这种方法的是,如果我的父级发生了某些变化,我必须编辑该父级继承的所有项目以修改版本号。有更好的方法吗?我希望我试图解释的内容可以被理解。

提前致谢。

最佳答案

What i don't like about this approach is that if something changes in my parent i have to edit all project which are inherited by that parent to modify the version number. Is there a better approach?

是的,有!看看Maven Versions Plugin ,具体来说:

versions:update-child-modules updates the parent section of the child modules of a project so the version matches the version of the current project.
For example, if you have an aggregator pom that is also the parent for the projects that it aggregates and the children and parent versions get out of sync, this mojo can help fix the versions of the child modules.
(Note you may need to invoke Maven with the -N option in order to run this goal if your project is broken so badly that it cannot build because of the version mis-match).

<小时/>

编辑:当然,使用 Maven3,您现在可以在子模块中包含 少的 元素:

Developers working in multi-module or multi-pom projects won't have to specify the parent version in every sub-module in Maven 3. Instead, you can add version-less parent elements.

Ref

关于maven-2 - Maven2继承,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/545131/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com