eclipse M2E:版本与父版本重复 - 为什么这是警告?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8263236/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
M2E: Version is duplicate of parent version - Why is this a warning?
提问by Doug Moscrop
I have several Maven projects that each have some common functionality or at least common configuration/dependencies. I extracted this in to a common pom.xml, and then modularlized several facets, for example persistence, Spring related dependencies, and so on - all in their own modules which inherit from this parent POM.
我有几个 Maven 项目,每个项目都有一些通用的功能或至少是通用的配置/依赖项。我将它提取到一个通用的 pom.xml 中,然后将几个方面模块化,例如持久性、与 Spring 相关的依赖项等等——所有这些都在它们自己的模块中,这些模块从这个父 POM 继承。
Right now, "Common" is version 1.0.0 and I have "ProjectA" that I wish to inherit from it. I receive the warning:
现在,“Common”是 1.0.0 版,我希望从它继承“ProjectA”。我收到警告:
Version is duplicate of parent version
版本与父版本重复
I don't fully understand why this is a warning. I thought I had the option of omitting the version from my project POM in order to inherit the version. (I do this for common modules - for example, common-spring adds additional common dependencies for Spring apps, and in fact, ProjectA actually inherits from common-spring.)
我不完全明白为什么这是一个警告。我以为我可以选择从我的项目 POM 中省略版本以继承该版本。(我对通用模块这样做——例如,common-spring 为 Spring 应用程序添加了额外的通用依赖项,实际上,ProjectA 实际上是从 common-spring 继承的。)
Isn't it just that - an option? If I change my ProjectA version to 1.0.1 or 2.0.0 all is well.
不就是这样——一个选项?如果我将 ProjectA 版本更改为 1.0.1 或 2.0.0,一切都很好。
回答by Fabricio Lemos
It′s just m2e trying to be clever because the version element (like group id) sometimes can be redundant and be can be inherited from the parent POM, so it would be safe to remove this element from your child POM.
这只是 m2e 试图变得聪明,因为 version 元素(如 group id)有时可能是多余的,并且可以从父 POM 继承,所以从你的子 POM 中删除这个元素是安全的。
But sometimes this is not a redundant information, like when the parent and the child project have different life cycles, and m2e should allow this warning to be disabled. Unfortunately there is no way to do this yet: http://dev.eclipse.org/mhonarc/lists/m2e-users/msg01961.html
但有时这不是多余的信息,比如当父项目和子项目具有不同的生命周期时,m2e 应该允许禁用此警告。不幸的是,目前还没有办法做到这一点:http: //dev.eclipse.org/mhonarc/lists/m2e-users/msg01961.html
UPDATE:As Duncan says bellow, in newer versions you can disable this warning.
更新:正如 Duncan 所说,在较新的版本中,您可以禁用此警告。
回答by Duncan Jones
Newer versions of m2e (since 1.1) now allow you to disable this warning.
较新版本的 m2e(自 1.1 起)现在允许您禁用此警告。
Preferences > Maven > Warnings > Disable "Version is duplicate of parent version" warning
首选项 > Maven > 警告 > 禁用“版本与父版本重复”警告
Original bug report: https://bugs.eclipse.org/bugs/show_bug.cgi?id=356796
原始错误报告:https: //bugs.eclipse.org/bugs/show_bug.cgi?id=356796
回答by DJDaveMark
If it really annoys you, use a property to supress the warning with some cunning sleight of hand:
如果它真的惹恼了您,请使用一个属性通过一些狡猾的手段来抑制警告:
<version>${api.version}</version>
<properties>
<api.version>0.0.1-SNAPSHOT</api.version>
</properties>
but all you'll really be doing is moving the warning to the console output:
但您真正要做的就是将警告移动到控制台输出:
[WARNING] Some problems were encountered while building the effective model for [project]
[WARNING] 'version' contains an expression but should be a constant.