Apache Kafka: …StringDeserializer is not an instance of …Deserializer

前端 未结 3 1275

In my simple application i am trying to instantiate a KafkaConsumer my code is nearly a copy of the code from javadoc (\"Automatic Offset Committing\"):

@Slf4j
p         


        
3条回答
  •  被撕碎了的回忆
    2021-01-23 06:08

    This might be the problem with Kafka classloading.
    Setting classloader to null might help.

    ...
    Thread currentThread = Thread.currentThread();    
    ClassLoader savedClassLoader = currentThread.getContextClassLoader();
    
    currentThread.setContextClassLoader(null);
    KafkaConsumer consumer = new KafkaConsumer<>(props);
    
    currentThread.setContextClassLoader(savedClassLoader);
    ...
    

    There is full explanation:
    https://stackoverflow.com/a/50981469/1673775

提交回复
热议问题