英文:
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
<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 ?
答案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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论