welcome to my blog

问题描述: SpringBoot整合kafka, 执行最基本的测试代码时报错
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 
'org.springframework.kafka.config.internalKafkaListenerAnnotationProcessor': 
Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: 
Failed to instantiate [org.springframework.kafka.annotation.KafkaListenerAnnotationBeanPostProcessor]: 
Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/core/log/LogAccessor
	
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate
 [org.springframework.kafka.annotation.KafkaListenerAnnotationBeanPostProcessor]: 
 Constructor threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/core/log/LogAccessor
原因: spring kafka的版本和spring-boot-starter-parent不匹配

我用的spring-boot-starter-parent的版本是2.1.5, 但是用的是2.3.5的spring-kafka

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

#### 解决方法: 选择和spring-boot-starter-parent匹配的spring-kafka版本, 这里我将spring-kafka的版本降低为2.2.12即可正常运行代码

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐