Maven - Suppress Overriding managed version warning in Eclipse

93,886

Solution 1

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.

Solution 2

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 IDEA or Eclipse.
  • Ctrl + Click on the <parent> tag to open pom of parent, and need to click twice recursively to finally get to the pom file 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

Solution 3

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.

Share:
93,886
The Gilbert Arenas Dagger
Author by

The Gilbert Arenas Dagger

Updated on July 09, 2022

Comments

  • The Gilbert Arenas Dagger
    The Gilbert Arenas Dagger almost 2 years

    I am using spring-boot, and experienced an error similar to the one described here. I added the following to my pom.xml.

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

    I am overriding the validation-api 1.0.0 dependency defined in my parent pom.xml, by way of Spring boot, and this gives the pesky warning message:

    Overriding managed version 1.0.0.GA for validation-api

    How can I permanently suppress this warning message in Eclipse? It shows up both in my pom.xml and my problems view.

  • Mohammad Faisal
    Mohammad Faisal almost 9 years
    this worked for removing warning shown in eclipse but I am still unable to build the project. getting the error: Rule 0: org.commonjava.maven.enforcer.rule.EnforceManagedDepsRule failed with message:The following 2 dependencies are NOT using a managed version
  • Eric
    Eric almost 8 years
    This is a bad way to solve the issue, because it might broken the dependency of other library.
  • S.potty
    S.potty over 7 years
    spring-boot use the the default version,which is may be declared in the pom file as the element <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>1.5.1.RELEASE</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> ,you should declare your own version to overwrite the default version.