springboot 中使用activemq的步骤:

1、pom中引入jar包:

2、spring boot配置文件中配置activemq

3、application 中添加对应的bean生成规则

4、发送消息

遇到的问题:

jmsmessagingtemplate 注入不成功,spring初始化错误,异常如下,只要按照步骤三就可以了:

springboot整合activemq时报jmsmessagingtemplate未加载错误

错误现象

bean method ‘jmsmessagingtemplate’ in ‘jmsautoconfiguration.messagingtemplateconfiguration’ not loaded because ancestor org.springframework.boot.autoconfigure.jms.jmsautoconfiguration did not match

网上解决方案

网上最多的方案是:application.properties中配置项的行尾有空格。检查没有,排除了这种可能。

第二种解决方案是:按如下方式将配置spring.activemq.pool.enabled改为false

启动springboot是不报错了,但是要发的消息也没进队列。至于为什么就不报错了,还没搞明白。如有高人请指点一二。

解决方案

查看activemqconnectionfactoryconfiguration类,自动配置发现需要引入下面这个依赖:

将依赖引入pom,再启动springboot,搞定!

以上为个人经验,希望能给大家一个参考,也希望大家多多支持www.887551.com。