Spring Cloud Contract - ContractVerifierTest - 找不到符号

Spring Cloud Contract - ContractVerifierTest - cannot find symbol

请问关于 Spring 云合同的小问题。

我正在尝试为我的 Spring 执行器健康端点编写一个基本合同。

这是一个带有 JUnit 5 Jupiter 5.7.0 的 Spring Webflux 2.4.1 项目,我是服务器(我向我的客户公开执行器健康端点,因此,我想编写合同) .

因此,我导入了actuator jar,以及contract verifier:

            <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 测试 class .将 testFramework 属性 设置为 JUNIT5 或迁移到默认使用 JUNIT5 的最新 Spring Cloud Contract 3.0.0 插件。