一、背景
首次使用Spring integration集成mqtt,按照网上的各种指导文档,写完后无法启动,一直报错:
Parameter 0 of constructor in com.xxxx.xxxx required a bean of type 'com.xxxx.xxxx' that could not be found.
Action:
Consider defining a bean of type 'com.xxxx.xxxx' in your configuration.
无法注入的这个是使用 @MessagingGateway注解的一个接口
二、原因:
下载@MessagingGateway的源码,可以看到这样一些注释
大意就是, @MessagingGateway注解需要配合 @IntegrationComponentScan和@Configuration注解使用。@ComponentScan无法扫描到。
吐槽一下,网上写文档的这些大哥,能不能靠谱点,参考了那么多文档,就没一个提到这事的,就算抄,好歹也测试一下啊!!!