APi 使用 spring 云合同时不兼容
APi incompatibility when using spring cloud contract
我正在尝试在示例生产者项目中使用 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])
我正在使用 Spring Boot 1.5.14.RELEASE、Edgware.SR3、Java 1.8 和 spring-cloud-contract-maven-plugin 1.2.4.RELEASE
我试过使用 spring-cloud-contract 在线教程中的示例来尝试使用插件、Spring 云和 spring 启动的版本,但我不能似乎摆脱了不兼容错误。
我的代码在这里 - https://github.com/craigmgordon/spring-cloud-contract/tree/Phase2/creditcheckservice-producer 如果有帮助
我已经成功构建了您的项目。您的合同中有一个错误(引号太多)
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 个版本不匹配
我正在尝试在示例生产者项目中使用 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])
我正在使用 Spring Boot 1.5.14.RELEASE、Edgware.SR3、Java 1.8 和 spring-cloud-contract-maven-plugin 1.2.4.RELEASE
我试过使用 spring-cloud-contract 在线教程中的示例来尝试使用插件、Spring 云和 spring 启动的版本,但我不能似乎摆脱了不兼容错误。
我的代码在这里 - https://github.com/craigmgordon/spring-cloud-contract/tree/Phase2/creditcheckservice-producer 如果有帮助
我已经成功构建了您的项目。您的合同中有一个错误(引号太多)
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 个版本不匹配