【发布时间】: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