我正在尝试为Spring云流创建Spring云合约。我有源,处理器和接收器。源使用SourcePollingChannelAdapte。合同groovy文件如下所示:
package contracts.messaging
import org.springframework.cloud.contract.spec.Contract
Contract.make {
description("""
Sends a non XhubJobState in Message
""")
// Label by means of which the output message can be triggered
label 'accpetable_message'
// input to the contract
input {
// the contract will be triggered by a method
triggeredBy('verifyValidXhubJobState()')
}
// output message of the contract
outputMessage {
// destination to which the output message will be sent
sentTo 'verifications'
// the body of the output message
body([
jobName:"Invalid_Destinations"
])
}
}
当尝试进行maven安装时,我得到了例外:
"Exception took place while trying to resolve the destination. Will assume the name [verifications]
java.lang.NullPointerException: null
at org.springframework.cloud.contract.verifier.messaging.stream.StreamStubMessages.resolvedDestination(StreamStubMessages.java:89)......."
我在application.properties文件
中定义了以下的propery"spring.cloud.stream.bindings.output.destination= verifications"
我是否遗漏了配置中的内容?
答案 0 :(得分:0)
我还没有看到你的代码,但我只能猜到你的基类中你错过了这些注释 - https://github.com/spring-cloud-samples/spring-cloud-contract-samples/blob/master/producer/src/test/java/com/example/BeerMessagingBase.java#L14-L19。您的上下文没有开始,所以没有注入字段,这就是您获得NPE的原因。