Error creating bean with name ‘kafkaTemplate’…
问题
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.autoconfigure.kafka.KafkaAnnotationDrivenConfiguration]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘kafkaTemplate’ defined in class path resource [org/springframework/boot/autoconfigure/kafka/KafkaAutoConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.kafka.core.KafkaTemplate] from ClassLoader [org.springframework.boot.loader.LaunchedURLClassLoader@439f5b3d]
。。。。。。
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘kafkaTemplate’ defined in class path resource [org/springframework/boot/autoconfigure/kafka/KafkaAutoConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.kafka.core.KafkaTemplate] from ClassLoader [org.springframework.boot.loader.LaunchedURLClassLoader@439f5b3d]
。。。。。。
Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.kafka.core.KafkaTemplate] from ClassLoader [org.springframework.boot.loader.LaunchedURLClassLoader@439f5b3d]
。。。。。。
Caused by: java.lang.NoClassDefFoundError: org/apache/kafka/clients/consumer/ConsumerGroupMetadata
。。。。。。
Caused by: java.lang.ClassNotFoundException: org.apache.kafka.clients.consumer.ConsumerGroupMetadata
解决办法
springboot2.2.x 对应kafka2.3.x和2.4.x 版本
springboot2.3.x 对应kafka2.5.x 版本