首页 > 其他 > 详细

【ActiveMQ】消息生产者自动注入报错:Could not autowire. No beans of 'JmsMessagingTemplate' type found

时间:2017-11-29 15:58:53      阅读:2017      评论:0      收藏:0      [点我收藏+]

使用ActiveMQ过程中,定义消息生产者:

技术分享图片
package com.sxd.jms.producer;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.stereotype.Service;

import javax.jms.Destination;


@Service("producer")
public class Producer1 {

    @Autowired // 也可以注入JmsTemplate,JmsMessagingTemplate对JmsTemplate进行了封装
    private JmsMessagingTemplate jmsTemplate;
    // 发送消息,destination是发送到的队列,message是待发送的消息

    public void sendMessage(Destination destination, final String message){
        jmsTemplate.convertAndSend(destination, message);
    }

}
View Code

 

但是IDE报错:

技术分享图片

启动编译,依旧是报错:

Description:

Field jmsTemplate in com.sxd.jms.producer.Producer1 required a bean of type ‘org.springframework.jms.core.JmsMessagingTemplate‘ that could not be found.
    - Bean method ‘jmsMessagingTemplate‘ not loaded because Ancestor org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration did not match


Action:

Consider revisiting the conditions above or defining a bean of type ‘org.springframework.jms.core.JmsMessagingTemplate‘ in your configuration.

技术分享图片

 

解决方式:

因为application.properties中配置ActiveMQ的相关配置后面有空格:

技术分享图片

把配置后面的空格去掉。保存,重新编译。

解决了!!!!

 

【ActiveMQ】消息生产者自动注入报错:Could not autowire. No beans of 'JmsMessagingTemplate' type found

原文:http://www.cnblogs.com/sxdcgaq8080/p/7920560.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!