如何解决Spring Cloud Contract - ContractVerifierTest - 找不到符号
关于 Spring Cloud 合同的小问题。
我正在尝试为我的 Spring Actuator 运行状况端点编写基本合同。
这是一个带有 JUnit 5 Jupiter 5.7.0 的 Spring Webflux 2.4.1 项目,我是服务器(我将执行器健康端点暴露给我的客户,因此,我想编写合同)。
因此,我导入了执行器 jar 和合约验证器:
<artifactId>spring-boot-starter-actuator</artifactId>
<artifactId>spring-cloud-starter-contract-verifier</artifactId>
我刚刚在我的资源文件夹中写了一个简单的合同,删除了其他所有内容:
request:
method: GET
url: /actuator/health
headers:
Content-Type: application/json
response:
status: 200
运行 mvn clean install 时,我得到:
target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierTest.java:[3,17] cannot find symbol
symbol: class Test
location: package org.junit
target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierTest.java:[4,17] cannot find symbol
symbol: class Rule
location: package org.junit
target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/ContractVerifierTest.java:[15,10] cannot find symbol
symbol: class Test
location: class org.springframework.cloud.contract.verifier.tests.ContractVerifierTest
可能的根本原因是什么,请问如何解决?
谢谢
解决方法
显然,您选择了最新的 Boot 而不是最新的 Spring Cloud Contract 版本,假设您使用的是 JUnit5,并且您的导入显示您正在生成 JUnit4 测试类。将 testFramework
属性设置为 JUNIT5
或迁移到默认使用 JUNIT5 的最新 Spring Cloud Contract 3.0.0 插件。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。