摘要
对于java的kafka集成,一般选用springboot集成kafka,但可能由于对接方kafka老旧、kafka不安全等问题导致kafak版本与spring版本不兼容,这个时候就得自己根据kafka客户端api集成了。
一、springboot集成kafka
具体官方文档地址:https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/

1、加入依赖,spring-boot-starter-web和spring-kafka 的版本号可以看它们依赖的spring版本是否一致,这里pom依赖如下:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.7.9</version>
</dependency>
<dependency>
<groupId>org.springframework.kafka</groupId>
<artifactId>spring-kafka</artifactId>
<version>2.9.6</version>
</dependency>
2、添加application.yml配置,具体如下:
server:
port: 8087
spring:
mvc:
pathmatch:
matching-strategy: ant_path_matcher
kafka:
bootstrap-servers: 192.168.189.128:9092,92.168.189.128:9093,192.168.189.128:9094
consumer:
properties:
group: