Spring 集成 Kafka 不工作

Spring Integration Kafka not working

我正在尝试使用 Kafka 和 Spring Boot 探索 Spring 集成。我正在学习本教程 Spring Integration and Kafka

我正在使用该文档中提供的依赖项,但出现以下异常

Caused by: org.xml.sax.SAXParseException: cvc-complex-type.3.2.2: Attribute 'compression-codec' is not allowed to appear in element 'int-kafka:producer-configuration'.

我认为这是一个 jar 不匹配问题,但我无法解决它,我尝试多次更改版本,但组合对我不起作用。请在下面找到我的 gradle 依赖项。

compile('org.springframework.boot:spring-boot-starter-integration')
compile('org.springframework.boot:spring-boot-starter')
compile('org.apache.kafka:kafka_2.10:0.8.1.1')
compile('org.springframework.integration:spring-integration-kafka:2.1.0.RELEASE')
compile('org.springframework.integration:spring-integration-java-dsl:1.1.0.M1') 

如果您需要有关这方面的更多详细信息,请告诉我。

那是一篇基于 1.x 版本的非常古老的文章;配置发生了很大变化 - 请参阅 spring-kafka 参考手册中更新的 Spring Integration Kafka 文档。

Spring 集成 Kafka (2.x) 现在基于 Spring Kafka 项目。

http://projects.spring.io/spring-kafka/

还有一个 sample application 但它使用 Java 配置,而不是 XML。

我使用了以下依赖项并且它们有效。

compile('org.springframework.boot:spring-boot-starter')
compile('org.springframework.integration:spring-integration-stream')
compile('org.springframework.integration:spring-integration-kafka:2.1.0.RELEASE')
compile('org.springframework.integration:spring-integration-java-dsl:1.1.0.M1')