org.springframework.context.ApplicationContextException: Failed to start bean 'org.springframework.kafka.config.internalKafkaListenerEndpointRegistry

空扰寡人 提交于 2019-12-01 14:24:06

After spending many hours I found that I should be using below in KafkaConsumerConfig too.

With the below changes code works fine.

props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
Kamesh

The issue may caused due to mismatch of Spring boot version and Kafka version. I was able to resolve with the following matrix.

Spring boot version :

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

Kafka version maven dependency from Spring boot version

    <dependency>
        <groupId>org.springframework.kafka</groupId>
        <artifactId>spring-kafka</artifactId>
    </dependency> 

Kafka version : kafka_2.12-2.2.0
Zookeeper version : apache-zookeeper-3.5.5

Application.yml file details as below :

server:
  port: 9000
spring:
  kafka:
    consumer:
      bootstrap-servers:
      - localhost:9092
      group-id: group_id
      auto-offset-reset: earliest
      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
      value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
    producer:
      bootstrap-servers:
      - localhost:9092
      key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
      value-deserializer: org.apache.kafka.common.serialization.StringDeserializer 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!