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