简体   繁体   English

Spring Cloud Contract-resolveDestination中的NullPointerException

[英]Spring Cloud Contract - NullPointerException in resolvedDestination

I am trying to create Spring cloud contract for Spring cloud stream. 我正在尝试为Spring云流创建Spring Cloud合同。 I have source, processor and sink. 我有源,处理器和接收器。 The source uses SourcePollingChannelAdapte. 源使用SourcePollingChannelAdapte。 The contract groovy file looks like this: 合同常规文件如下所示:

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"              
        ])
    }
}

When try to do maven install I get the exception: 当尝试执行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)......."

I have defined following propery set in application.properties file 我已经在application.properties文件中定义了以下属性

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

Am I missing something in the configuration? 我在配置中缺少什么吗?

I haven't seen your code but I can only guess that in your base class you're missing these annotations - https://github.com/spring-cloud-samples/spring-cloud-contract-samples/blob/master/producer/src/test/java/com/example/BeerMessagingBase.java#L14-L19 . 我没有看到您的代码,但我只能猜测您的基类中缺少这些注释-https: //github.com/spring-cloud-samples/spring-cloud-contract-samples/blob/master/ producer / src / test / java / com / example / BeerMessagingBase.java#L14-L19 Your context wasn't started so the fields weren't injected, that's why you get NPE. 您的上下文尚未开始,因此没有注入字段,这就是为什么您获得NPE的原因。

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

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