SpringBoot整合RocketMQ调用ExtRocketMQTemplate报错:Bean named ‘rocketMQTemplate‘ is expected to be of type

运行时报错展示:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'MQController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'rocketMQTemplate' is expected to be of type 'com.study.springboot.rocketmq.config.ExtRocketMQTemplate' but was actually of type 'org.apache.rocketmq.spring.core.RocketMQTemplate'
	at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessProperties(CommonAnnotationBeanPostProcessor.java:337) ~[spring-context-5.2.2.RELEASE.jar:5.2.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1422) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.2.RELEASE.jar:5.2.2.RELEASE]

ExtRocketMQ配置代码:
在这里插入图片描述
业务类代码:
SpringBoot整合RocketMQ调用ExtRocketMQTemplate报错:Bean named ‘rocketMQTemplate‘ is expected to be of type_第1张图片
解决方法
额外的模板变量名称不要用rocketMQTemplate,换一个。
SpringBoot整合RocketMQ调用ExtRocketMQTemplate报错:Bean named ‘rocketMQTemplate‘ is expected to be of type_第2张图片
启动
SpringBoot整合RocketMQ调用ExtRocketMQTemplate报错:Bean named ‘rocketMQTemplate‘ is expected to be of type_第3张图片
消息发送测试
在这里插入图片描述

你可能感兴趣的:(bug处理,java,spring,boot)