8

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

Guru Cse
  • 2,805
  • 2
  • 18
  • 15

5 Answers5

4

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

3
  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
Guru Cse
  • 2,805
  • 2
  • 18
  • 15
1
<dependency>
    <groupId>io.rest-assured</groupId>
    <artifactId>rest-assured</artifactId>
    <version>${restassured.version}</version>
    <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-xml</artifactId>
        </exclusion>
    </exclusions>
</dependency>
MohdTausif
  • 498
  • 4
  • 13
0

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)

vlatko606
  • 909
  • 1
  • 13
  • 21
0

Gradle dependencies:

testImplementation('io.rest-assured:rest-assured:5.3.0')  {
    exclude group: 'org.apache.groovy', module: 'groovy'
    exclude group: 'org.apache.groovy', module: 'groovy-xml'
}
Alexey Bril
  • 479
  • 4
  • 14