简体   繁体   English

Spring Cloud Contract 无法启动 Stub Runner

[英]Spring Cloud Contract failed to start Stub Runner

I've made a Consumer side spring-cloud-contract test and it fails on starting the stub server.我已经进行了消费者端 spring-cloud-contract 测试,但它在启动存根服务器时失败。 I see in the logs it is able to download and unpack the stub.jar but then it fails with the following Exception:我在日志中看到它能够下载并解压缩 stub.jar,但随后失败并出现以下异常:

initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'batchStubRunnerBeanPostProcessor' defined in class path resource [org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfiguration.class]: Unsatisfied dependency expressed through method 'batchStubRunnerBeanPostProcessor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'batchStubRunner' defined in class path resource [org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.contract.stubrunner.BatchStubRunner]: Factory method 'batchStubRunner' threw exception; nested exception is java.lang.ClassCastException: org.springframework.cloud.contract.verifier.builder.handlebars.HandlebarsJsonPathHelper incompatible with com.github.jknack.handlebars.Helper
2022-07-11 19:20:59.683  INFO 14704 --- [    Test worker] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-07-11 19:20:59.694 ERROR 14704 --- [    Test worker] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'batchStubRunnerBeanPostProcessor' defined in class path resource [org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfiguration.class]: Unsatisfied dependency expressed through method 'batchStubRunnerBeanPostProcessor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'batchStubRunner' defined in class path resource [org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.cloud.contract.stubrunner.BatchStubRunner]: Factory method 'batchStubRunner' threw exception; nested exception is java.lang.ClassCastException: org.springframework.cloud.contract.verifier.builder.handlebars.HandlebarsJsonPathHelper incompatible with com.github.jknack.handlebars.Helper
  at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:800) ~[spring-beans-5.3.20.jar:5.3.20]

I am using mavenBom "org.springframework.cloud:spring-cloud-dependencies:2021.0.3" with Java 8. It has chosen to use "spring-cloud-contract-stub-runner-3.1.3.jar:3.1.3".我在 Java 8 中使用 mavenBom "org.springframework.cloud:spring-cloud-dependencies:2021.0.3"。它选择使用 "spring-cloud-contract-stub-runner-3.1.3.jar:3.1.3 ”。

Figured out it was due to a wiremock dependency I had in my build.gradle file.发现这是由于我在build.gradle文件中的一个wiremock依赖。

Commenting out the below dependency fixed the issue:注释掉以下依赖项解决了这个问题:

testImplementation 'com.github.tomakehurst:wiremock-jre8:2.33.2'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM