1

我正在尝试为 Spring 云流创建 Spring Cloud 合同。我有源、处理器和接收器。源使用 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 文件中定义了以下属性集

"spring.cloud.stream.bindings.output.destination= verifications"

我在配置中遗漏了什么吗?

4

1 回答 1

0

我还没有看到你的代码,但我只能猜测在你的基类中你缺少这些注释 - https://github.com/spring-cloud-samples/spring-cloud-contract-samples/blob/master/生产者/src/test/java/com/example/BeerMessagingBase.java#L14-L19。您的上下文尚未启动,因此未注入字段,这就是您获得 NPE 的原因。

于 2017-05-19T05:21:53.650 回答