Conflicting module versions. Module [groovy-xml is loaded in version 4.x.x and you are trying to load version 3.x.x

Viewed 2162

I am working to setup wiremock for springboot rest api and using rest assured and spring-cloud-starter-contract-stub-runner from spring cloud. when i run the sample integration test i encounter module conflict error

3 Answers
  1. check your dependency tree of pom file. The reason for the error is there were two groovy libs in your class path with different versions and this is causing the conflict
  2. One from rest-assured dependency and other from spring-cloud-starter-contract-stub-runner dependency
  3. Solution is to remove rest assured and replace it with restdocs-api-spec-restassured dependency. This way you can use rest assured with out additional groovy dependency . your class path will only have 1 groovy from spring-cloud-starter-contract-stub-runner dependency

1 just manually remove rest-assured dependency from POM file.

2 add to the pom file

<dependency>
        <groupId>com.epages</groupId>
        <artifactId>restdocs-api-spec-restassured</artifactId>
        <version>0.10.4</version>
    </dependency>

3 Maven clean

4 Maven Compile

5 Maven - Reload(refresh)

Found this workaround on Rest Assured's GitHub page. You replace Rest Assured's dependency with this one

<dependency>
        <groupId>io.rest-assured</groupId>
        <artifactId>rest-assured</artifactId>
        <version>5.1.1</version>
        <scope>test</scope>
        <exclusions><!-- https://www.baeldung.com/maven-version-collision -->
            <exclusion>
                <groupId>org.apache.groovy</groupId>
                <artifactId>groovy</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.apache.groovy</groupId>
                <artifactId>groovy-xml</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>io.rest-assured</groupId>
        <artifactId>json-schema-validator</artifactId>
        <version>5.1.1</version>
        <scope>test</scope>
    </dependency>

Rest Assured's Github Page

Related