我试图在一个示例生产者项目中使用spring合同。然而,由于以下原因,我在POM中看到了错误
Multiple annotations found at this line:
- Execution default-generateTests of goal org.springframework.cloud:spring-cloud-contract-maven-plugin:1.2.4.RELEASE:generateTests failed: An API
incompatibility was encountered while executing org.springframework.cloud:spring-cloud-contract-maven-plugin:1.2.4.RELEASE:generateTests:
java.lang.VerifyError: Bad <init> method call from inside of a branch Exception Details: Location: org/springframework/cloud/contract/verifier/
TestGenerator.<init>(Lorg/springframework/cloud/contract/verifier/config/ContractVerifierConfigProperties;)V @75: invokespecial Reason: Error exists in the
bytecode Bytecode: 0000000: b800 244d b800 2a9a 0006 a700 472a 2b2c 0000010: 122b 3212 02b9 0031 0200 1233 b800 39c0 0000020: 0033 2c12
3a32 123c 2c12 3d32 2bb9 0041 0000030: 0200 2c12 4232 1202 b900 3102 002b b900 0000040: 4605 0012 3cb8 0039 c000 3cb7 0049 a700
0000050: 2c2a 2bb8 004d 2c12 4e32 123c 2c12 4f32 0000060: 2bb9 0041 0200 b800 4d2b b900 4605 0012 0000070: 3cb8 0039 c000 3cb7 0049 b1
Stackmap Table: append_frame(@13,Object[#83])我正在使用SpringBoot1.5.14 contract,Edgware.SR3,Java1.8和Spring contract plugin 1.2.4。
我试着使用Spring合同在线教程中的例子,尝试使用插件、spring和spring启动的版本,但我似乎无法消除不兼容错误。
我的代码在这里-如果它有帮助的话,https://github.com/craigmgordon/spring-cloud-contract/tree/Phase2/creditcheckservice-producer
发布于 2018-06-15 12:37:34
我成功地构建了你的项目。你的合同有错误(报价太多)
import org.springframework.cloud.contract.spec.Contract;
Contract.make{
request{
method 'POST'
url '/credit-scores'
body """
{
"citizenNumber" : 1234
}
""" // you had an extra quote here
headers{
contentType applicationJson()
}
}
response{
status 200
body """
{
"score" : "HIGH"
}
"""
headers{
contentType applicationJson()
}
}
}执行
➜ creditcheckservice-producer git:(Phase2) ✗ ./mvnw clean install
...
Results :
Tests in error:
CreditcardserviceTest.validate_shouldGrantACreditScoreOfHighToACitizen:24 » IllegalState
Tests run: 2, Failures: 0, Errors: 1, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 7.711 s
[INFO] Finished at: 2018-06-15T14:36:14+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project creditcheckservice-producer: There are test failures.
[ERROR]
[ERROR] Please refer to /Users/marcingrzejszczak2/repo/contract-issues/so/foo/spring-cloud-contract/creditcheckservice-producer/target/surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException更新:
结果发现java版本中存在不匹配现象。
https://stackoverflow.com/questions/50875441
复制相似问题