无法在尝试生成Spring Cloud合同时找到ContractVerifierUtil类。

huangapple go评论62阅读模式
英文:

Cannot find ContractVerifierUtil class while trying to generate spring cloud contracts

问题

我正试图为我的API生成云合同,但由于生成的测试类无法找到以下依赖项中的类,构建失败。

 编译失败--导入静态 org.springframework.cloud.contract.verifier.util.ContractVerifierUtil.*;

[错误] ContractVerifierTest.java:[18,63] 找不到符号
[错误]   符号:   类 ContractVerifierUtil
[错误]   位置: package org.springframework.cloud.contract.verifier.util

这是我在 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>

以及我的 Maven 插件配置

       <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>

我已经查看了类似的 帖子,但版本与 Spring Cloud 文档 相容。

表格 1. 发布系列 Spring Boot 相容性
发布系列	Boot 版本
Hoxton

2.2.x

我已尝试过多个版本,但似乎不起作用。关于我遗漏了什么的任何指导?

英文:

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

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

and my maven plugin configuration

       &lt;plugin&gt;
            &lt;groupId&gt;org.springframework.cloud&lt;/groupId&gt;
            &lt;artifactId&gt;spring-cloud-contract-maven-plugin&lt;/artifactId&gt;
            &lt;version&gt;2.1.1.RELEASE&lt;/version&gt;
            &lt;extensions&gt;true&lt;/extensions&gt;
            &lt;configuration&gt;
                &lt;baseClassForTests&gt;
                    com.test.specValidation.ContractTest
                &lt;/baseClassForTests&gt;
            &lt;/configuration&gt;
        &lt;/plugin&gt;

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 ?

答案1

得分: 0

请将插件的版本与合同依赖的版本保持一致。您正在使用版本为2.2.3.RELEASE的 verifier,然而插件的版本为2.1.1.RELEASE。它们必须使用相同的版本。

英文:

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.

huangapple
  • 本文由 发表于 2020年7月27日 11:38:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/63108347.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定