3

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?

secondbreakfast
  • 4,194
  • 5
  • 47
  • 101
  • 4
    run mvn dependency:tree, and find out which other dependency has this dependency. – JB Nizet Nov 27 '17 at 20:35
  • 3
    Check the dependency tree, who else adds `spring-restdocs-core`, maybe someone (closer to your project) overrides the version. Check your `dependencyManagement` whether it's overridden there. If you have a Maven parent (eg. Spring-Boot-parent) check the version defined there. These can all override a dependency version. – helospark Nov 27 '17 at 20:36
  • 2
    If you have `spring-boot-starter-parent` dependency, you should not try to override the managed version (so don't add the version when adding the dependency), otherwise the dependency versions can be different. If you manually want to override, you have to define `spring-restdocs-core` as well. – helospark Nov 27 '17 at 20:42

1 Answers1

3

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!

Andy Wilkinson
  • 108,729
  • 24
  • 257
  • 242
unigeek
  • 2,656
  • 27
  • 27