Search code examples
javaspringspring-cloudmaven-pluginspring-cloud-contract

Cannot find ContractVerifierUtil class while trying to generate spring cloud contracts


I'm trying to generate cloud contracts for my API but the build is failing as the generated test class cannot find the below class from the dependency.

 Compilation failure--import static org.springframework.cloud.contract.verifier.util.ContractVerifierUtil.*;

[ERROR] ContractVerifierTest.java:[18,63] cannot find symbol
[ERROR]   symbol:   class ContractVerifierUtil
[ERROR]   location: package org.springframework.cloud.contract.verifier.util

These are my dependencies in my pom.xml

    <dependency>
        <groupId>com.atlassian.oai</groupId>
        <artifactId>swagger-request-validator-mockmvc</artifactId>
        <version>2.10.1</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <version>2.3.0.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-contract-verifier</artifactId>
        <version>2.2.3.RELEASE</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-dependencies</artifactId>
        <version>Hoxton.RELEASE</version>
        <type>pom</type>
        <scope>import</scope>
    </dependency>

and my maven plugin configuration

       <plugin>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-contract-maven-plugin</artifactId>
            <version>2.1.1.RELEASE</version>
            <extensions>true</extensions>
            <configuration>
                <baseClassForTests>
                    com.test.specValidation.ContractTest
                </baseClassForTests>
            </configuration>
        </plugin>

I've looked at the similar post but the version looks compatible as per spring cloud docs

Table 1. Release train Spring Boot compatibility
Release Train   Boot Version
Hoxton

2.2.x

I've tried with multiple versions but doesn't seem to work. Any guidance on what I'm missing ?


Solution

  • Please align the version of the plugin with the version of the contract dependency. You're using verifier in version 2.2.3.RELEASE however the plugin is in 2.1.1.RELEASE. They must be used in the same version.