【问题标题】:Spring Cloud Contract - ContractVerifierTest - cannot find symbolSpring Cloud Contract - ContractVerifierTest - 找不到符号
【发布时间】:2021-01-04 23:06:11
【问题描述】:

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

请问根本原因是什么,如何解决?

谢谢

【问题讨论】:

    标签: java spring-cloud-contract


    【解决方案1】:

    显然您选择了最新的 Boot 而不是最新的 Spring Cloud Contract 版本,假设您使用的是 JUnit5,并且您的导入表明您正在生成一个 JUnit4 测试类。要么将testFramework 属性设置为JUNIT5,要么迁移到默认使用JUNIT5 的最新Spring Cloud Contract 3.0.0 插件。

    【讨论】:

    • 两种解决方案都有效。非常感谢马辛
    猜你喜欢
    • 2018-12-27
    • 2017-09-29
    • 2020-10-24
    • 1970-01-01
    • 2017-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多