Spring 云合约生产者无法发送消息

Spring Cloud Contract producer cannot send message

我正在尝试将 Spring Cloud Contract 合并到现有项目中。我在 REST 方面取得了一些成功,但我正在努力设置消息传递方面。

到目前为止,我已经与生产者建立了合同,它确实在 target/generated-test-sources/contracts 中进行了测试。我还为测试设置了一个基础class。

我无法克服这个错误:

2017-09-08 17:10:51.759 ERROR - --[]- [ main] o.s.c.c.v.m.stream.StreamStubMessages : Exception took place while trying to resolve the destination. Will assume the name [invites]

org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.cloud.stream.config.ChannelBindingServiceProperties' available at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:353) at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:340) at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1093) at org.springframework.cloud.contract.verifier.messaging.stream.StreamStubMessages.resolvedDestination(StreamStubMessages.java:86) at org.springframework.cloud.contract.verifier.messaging.stream.StreamStubMessages.receive(StreamStubMessages.java:73) at org.springframework.cloud.contract.verifier.messaging.stream.StreamStubMessages.receive(StreamStubMessages.java:110) at org.springframework.cloud.contract.verifier.messaging.stream.StreamStubMessages.receive(StreamStubMessages.java:36) at org.springframework.cloud.contract.verifier.messaging.internal.ContractVerifierMessaging.receive(ContractVerifierMessaging.java:40) at org.springframework.cloud.contract.verifier.tests.email.MessagingTest.validate_invitedContract(MessagingTest.java:27)

以后

2017-09-08 17:10:51.759 ERROR - --[]- [ main] o.s.c.c.v.m.stream.StreamStubMessages : Exception occurred while trying to read a message from a channel with name [invites]

org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'invites' available at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:687) at org.springframework.beans.factory.support.AbstractBeanFactory.getMergedLocalBeanDefinition(AbstractBeanFactory.java:1207) at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:284) at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)

我的 application.yml 文件在 src/test/resources 下:

spring: cloud: stream: bindings: output: content-type: application/json destination: invites

我有以下依赖项:

`
    <!-- Spring Cloud Contract Deps -->
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-stream</artifactId>
        <version>1.2.2.RELEASE</version>
    </dependency>       

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-contract-verifier</artifactId>
        <version>1.1.3.RELEASE</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-stream-test-support</artifactId>
        <version>1.2.2.RELEASE</version>
        <scope>test</scope>
    </dependency>
    <!-- END SCC Deps -->`

我梳理了文档,观看了 Marcin 的演讲并查看了 Spring Cloud Contract 的示例,但我被卡住了。任何帮助将不胜感激。

第一期:

请使用发布列车。在发布序列中,我们知道没有无效的依赖项。

第二期:

您没有 @EnableBinding(Source.class) 注释。这就是 Stream 不知道如何绑定到 output 频道的原因。

如果您转到 Spring 云合同示例,您会在主应用程序 class (https://github.com/spring-cloud-samples/spring-cloud-contract-samples/blob/master/producer/src/main/java/com/example/ProducerApplication.java#L9) 上注意到这一行。在我将此行添加到您的代码后,上下文启动但测试失败,原因是消息未发送。