Spring boot 3.0整合RocketMQ不兼容的问题
问题发现:
*************************** APPLICATION FAILED TO START *************************** Description: Field rocketMQTemplate in com.spt.message.service.MqProducerService required a bean of type 'org.apache.rocketmq.spring.core.RocketMQTemplate' that could not be found. The injection point has the following annotations:- @org.springframework.beans.factory.annotation.Autowired(required=true) Action: Consider defining a bean of type 'org.apache.rocketmq.spring.core.RocketMQTemplate' in your configuration.
问题分析:
Springboot-3.0已经放弃了spring.plants自动装配,被/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports所取代
问题解决:
在resources下创建META-INF,然后在META-INF下创建文件:org.springframework.boot.autoconfigure.AutoConfiguration.imports
(创建完文件后,文件被扫描到,在Idea图标会变化,如果没有变说明没有生效,也可能是命名错误或者创建文件用的"."而不是"/")
更多参考:ISSUE #539] Feat: support SpringBoot 3.x by imp2002 · Pull Request #541 · apache/rocketmq-spring