Maven - Suppress Overriding managed version warning in Eclipse

后端 未结 4 1271
悲&欢浪女
悲&欢浪女 2021-01-31 15:32

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

    
            


        
4条回答
  •  臣服心动
    2021-01-31 16:04

    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 , to specify the version.

    e.g

            
                2.5.0.BUILD-SNAPSHOT
            
    

    How to find the property name:

    • Open your pom.xml in IDEA or Eclipse.
    • Ctrl + Click on the 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

提交回复
热议问题