spring集成kafka运行时报错:Failed to construct kafka producer] with root cause

Posted zhangphil

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring集成kafka运行时报错:Failed to construct kafka producer] with root cause相关的知识,希望对你有一定的参考价值。

spring集成kafka运行时报错:Failed to construct kafka producer] with root cause

org.apache.kafka.common.KafkaException: class org.apache.kafka.common.serialization.StringDeserializer is not an instance of org.apache.kafka.common.serialization.Serializer

如图:

解决方案,spring框架里面的kafka的消费者和生产者的key和value解析器用spring支持的,在application.properties配置spring支持的解析器:

spring.kafka.consumer.key-deserializer=org.springframework.kafka.support.serializer.StringOrBytesSerializer
spring.kafka.consumer.value-deserializer=org.springframework.kafka.support.serializer.JsonSerializer
spring.kafka.producer.key-serializer=org.springframework.kafka.support.serializer.StringOrBytesSerializer
spring.kafka.producer.value-serializer=org.springframework.kafka.support.serializer.JsonSerializer

以上是关于spring集成kafka运行时报错:Failed to construct kafka producer] with root cause的主要内容,如果未能解决你的问题,请参考以下文章

Simulink 运行时报错failed to create files 的解决方法

SpringBoot单元测试运行时报错:Failed to load ApplicationContext

SpringBoot单元测试运行时报错:Failed to load ApplicationContext

SpringBoot单元测试运行时报错:Failed to load ApplicationContext

SpringBoot单元测试运行时报错:Failed to load ApplicationContext

SpringBoot单元测试运行时报错:Failed to load ApplicationContext