Maven - Suppress Overriding managed version warning in Eclipse

余生长醉 提交于 2019-12-02 20:10:16

When that warning shows up, you can open the Quick-Fix menu on the warning (Ctrl+1) and select

Ignore this warning

This will add the comment on the version line, like :

<dependency>
   <groupId>javax.validation</groupId>
   <artifactId>validation-api</artifactId>
   <version>1.1.0.Final</version><!--$NO-MVN-MAN-VER$-->
</dependency>

Your problem is you manually added that comment on the wrong line.

Since the project is using spring-boot, a more proper answer could be found here: https://stackoverflow.com/a/35385268/1568658

(And since I got the same issue, and the above answer also is not very complete. I would add an answer here.)

Reason of issue:

spring-boot has defined many dependencies & their versions, when you use spring-boot as parent, these dependencies got inherited, and overriding one of the dependency with a different version would get the warning, because it might break other libraries' dependencies.

Solution:

Define a property for that dependency between <properties></properties>, to specify the version.

e.g

        <properties>
            <reactor.version>2.5.0.BUILD-SNAPSHOT</reactor.version>
        </properties>

How to find the property name:

  • Open your pom.xml in eclipse.
  • ctrl + click on the <parent> tag to open pom of parent, and need to click twice recursively to finally get to pom with artifactId as spring-boot-dependencies
  • Once you have opened that pom, search for your dependency, e.g servlet-api, and you can see the default version.

There is a document from spring explains it better: https://spring.io/blog/2016/04/13/overriding-dependency-versions-with-spring-boot

Dmitriy Bereza

Enter version that you need in main pom.

This warning means that you are trying to override artifact version that is defined in your main (top level) pom. Just enter version that you need in main pom and you don't even need to use <version /> in other poms for this dependency.

useful ! I resolve the problem. As the module pom file declare 9.2.12.M0 while the spring-boot refer to the V9.3 . I overwrite the V9.2 in the parent pom file. follow by "Eric Wang"

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!