1)引入maven依赖
我这里使用的是springboot 2.1.3.RELEASE 版本:
<dependency> <groupId>org.springframework.kafka</groupId> <artifactId>spring-kafka</artifactId> </dependency>
会引入一对的kafka包:
2)生产者配置:
所有配置参考kafka-clients-2.5.0.jar包里的org.apache.kafka.clients.producer.ProducerConfig类,并且在该类中可以查看所有配置项的默认值: CONFIG = (new ConfigDef()).define( 这里的define方法的第三个参数就是默认值
application.properties里可以这样配置(这里示例几个重要配置):
如果需要手动封装 @bean对象:
3)消费者配置:
end.
原文:https://www.cnblogs.com/zhuwenjoyce/p/13191163.html