【问题标题】:spring cloud stream binder kafka doesn't workspring cloud stream binder kafka 不起作用
【发布时间】:2019-06-05 11:06:43
【问题描述】:

现在我正在尝试使用 kafka 创建消息服务功能以使用spring-cloud-stream-bind-kafka,但效果不佳。

Configuration:
弹簧靴 1.4.2

build.gradle:

compile "org.springframework.cloud:spring-cloud-stream:2.0.1.RELEASE"
compile "org.springframework.cloud:spring-cloud-stream-binder-kafka:2.0.1.RELEASE"

code:

@EnableBindings(MessagePublish.class)
class MessageConfiguration {
}

interface MessagePublish {
    @Output("test")
    MessageChannel publish();
}

class TestService {
    @Autowired
    MessagePublish messagePublish;

    public void doSomething() {
        // do something
        messagePublish.publish().send(MessageBuilder.withPayload("test").build());
    }
}

当我用这个错误日志启动项目时它失败了

Caused by: org.springframework.boot.autoconfigure.condition.OnBeanCondition$BeanTypeDeductionException: Failed to deduce bean type for org.springframework.cloud.stream.config.BindingServiceConfiguration.bindingService
....
Caused by: java.lang.ClassNotFoundException: org.springframework.integration.support.converter.ConfigurableCompositeMessageConverter

我怀疑我的 Spring Boot 版本。版本太低了。
我觉得spring-cloud-stream-binder-kafka在spring boot 2.0版本或者其他原因下无法使用。

我不知道我该怎么做以及如何探索这种情况......
如果你能给我一点建议,我真的很感激你。

【问题讨论】:

  • 强烈推荐spring boot 2,改动太多了。我建议您从 start.spring.io 开始生成 pom 以获得正确的依赖项和版本
  • 我也想使用 spring boot 2,但我不能(也许..)。因为这个项目真的是巨大的遗产

标签: apache-kafka spring-cloud spring-cloud-stream


【解决方案1】:

如果您使用的是 Spring Boot 1.4.x 版本,那么您应该使用 Spring Cloud Camden 发行版。

https://github.com/spring-projects/spring-cloud/wiki/Spring-Cloud-Camden-Release-Notes

特别是,您应该使用以下版本:

compile "org.springframework.cloud:spring-cloud-stream:1.1.2.RELEASE"
compile "org.springframework.cloud:spring-cloud-stream-binder-kafka:1.1.2.RELEASE"

【讨论】:

  • 这些版本非常旧,不再受支持。甚至 Boot 1.5 也很快失去支持。
猜你喜欢
  • 2018-12-16
  • 1970-01-01
  • 1970-01-01
  • 2021-12-13
  • 2021-02-17
  • 1970-01-01
  • 2018-03-09
  • 1970-01-01
  • 2019-04-19
相关资源
最近更新 更多