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

x33g5p2x  于2022-03-04 转载在 Spring  
字(0.7k)|赞(0)|评价(0)|浏览(510)

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

相关文章

微信公众号

最新文章

更多