一、问题原因:
在整合springboot+activeMQ时,出现JmsMessagingTemplate注入失败问题:
文字:
Description:
Field jmsMessagingTemplate in com.it.activemq.activemq.service.impl.ProducerServiceImpl required a bean of type 'org.springframework.jms.core.JmsMessagingTemplate' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
The following candidates were found but could not be injected:
- Bean method 'jmsMessagingTemplate' in 'JmsAutoConfiguration.MessagingTemplateConfiguration' not loaded because Ancestor org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration did not match
Action:
Consider revisiting the entries above or defining a bean of type 'org.springframework.jms.core.JmsMessagingTemplate' in your configuration.
二、解决方法
1、检查配置文件末尾是否存在空格,如果存在,请删除
2、在pom.xml文件中添加依赖:
<dependency>
<groupId>org.messaginghub</groupId>
<artifactId>pooled-jms</artifactId>
<version>1.0.4</version>
</dependency>
三、产生问题原因:
在springboot2.0以下版本,需要添加的Maven依赖包为:
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-pool</artifactId>
</dependency>
如何是springboot2.0以上版本,需要添加的Maven依赖包为:
<dependency>
<groupId>org.messaginghub</groupId>
<artifactId>pooled-jms</artifactId>
<version>1.0.4</version>
</dependency>