Field kafkaProducer in StartMain required a bean of type 'com.test.KafkaProducer' that could not be found.
Consider defining a bean of type 'com.test.KafkaProducer' in your configuration.

解决办法:
在StartMain类增加对指定包扫描。
@RestController
@EnableAutoConfiguration
@ComponentScan(basePackages ={"com.test" })
public class StartMain {
public static void main(String[] args) throws Exception {
SpringApplication.run(StartMain.class, args);
}
}
ComponentScan 详解参考
https://blog.youkuaiyun.com/Lamb_IT/article/details/80918704
自定义扫描规则
https://blog.youkuaiyun.com/u010285684/article/details/79621548
本文详细介绍了在启动Spring Boot应用时遇到的FieldkafkaProducer找不到bean的问题,并提供了具体的解决方案,包括在StartMain类中增加指定包扫描的配置。
567

被折叠的 条评论
为什么被折叠?



