Spring Cloud Stream和gcp pub sub,活页夹问题

时间:2019-02-13 22:21:08

标签: spring-cloud spring-cloud-stream

我正在尝试使用GCP的Pub Sum作为活页夹在本地运行SCS应用程序。 ķ     米     嗯MM org.sm.Mpringframework.cloudkki         spring-cloud-gcp-starter-pubsub      中号 这是配置l

@Configu@Configukration
@EnableBindingkklk(Source.class)
public class TimerSourcek {

  @Bean
  @InboundChannelAdapter(channel = "channel", poller = @Poller(fixedDelay = "1000", maxMessagesPerPoll = "1"))
  public MessageSource<String> timerMessageSource() {
    return () -> new GenericMessage<>(new SimpleDateFormat("HH:mm:ss").format(new Date()));
  }
}

这是启动主应用程序时的错误消息:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-02-13 15:42:48.627 ERROR 22276 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.context.ApplicationContextException: Failed to start bean 'outputBindingLifecycle'; nested exception is java.lang.IllegalArgumentException: A default binder has been requested, but there is no binder available

我想在本地或针对我的GCP项目运行此代码。怎么办?

1 个答案:

答案 0 :(得分:2)

spring-cloud-gcp-starter-pubsub不会给您带来绑定器依赖性。 您还需要使用spring-cloud-gcp-pubsub-stream-binder

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-gcp-starter-pubsub</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-gcp-pubsub-stream-binder</artifactId>
    </dependency>

有关更多信息,请参见项目中的示例:https://github.com/spring-cloud/spring-cloud-gcp/tree/master/spring-cloud-gcp-samples