Search code examples
mavenspring-bootintellij-ideaspring-restdocs

Transitive dependency pulling in lower version than declared in POM


I am using version 1.2.2 of spring-restdocs-mockmvc in my Spring Boot application that I am developing with IntelliJ.

enter image description here

Taking a look at its POM, it declares the following dependency of spring-restdocs-core:

enter image description here

But for some reason, the compile version of spring-restdocs-core available to me during development does not match this, and keeps me stuck on version 1.1.2.

enter image description here

I have updated my repositories, refreshed, rebuilt, clean install, you name it, everything I could find on how to "refresh" the state of my Maven project, and nothing changes this. Any ideas?


Solution

  • There's a blog post here on spring.io that captures the issues pretty well and offers five different possible solutions from doing some XML sit ups with Maven to migrating your build to Gradle (thus dodging XML sit ups altogether). Looks like what that post presents as "option 2" might be the easiest for you, that is in your project:

    <properties>
        <spring-restdocs.version>1.2.2.RELEASE</spring-restdocs.version>
    </properties>
    

    Note that this does assume you're using spring-boot-starter-parent, which seems like a reasonable assumption. I believe that will get you the mockmvc dependency as well, so you can remove your existing declaration of that dependency. This link might also be useful. Hope it helps!