解决springboot+activemq启动报注解错误的问题

 更新时间:2021年07月26日 08:43:17   作者:取静舍浮  
这篇文章主要介绍了解决springboot+activemq启动报注解错误的问题,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教

springboot+activemq启动报注解错误

Description:
Field jmsMessagingTemplate in com.haozz.demo.mq.PromoteActProducer 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.

原因总结有以下3点原因:

1.spring.activemq.pool.enabled=true,线程池开启,后面有空格,且没有引入线程池包

       <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-pool</artifactId>
        </dependency>

2.springboot版本问题不支持,建议用2.0版本启动

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.1.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

猜想:估计是因为2.1.0+版本有自己的线程池管理,导致冲突

3.spring.activemq.pool.enabled=false,关闭线程池

springboot整合activemq踩过坑

启动时候就关闭了

配置如下

server:
 port: 8762
#    context-path: /memeber
eureka:
 client:
   service-url:
     defaultZone: http://localhost:8761/eureka/
spring:
   application:
       name: member
   redis:
       host: 127.0.0.1
       password: 123456
       port: 6379
       pool:
           max-idle: 100
           min-idle: 1
           max-active: 1000
           max-wait: -1
   datasource:
       name: test1
       url: jdbc:mysql://127.0.0.1:3306/dandan-member
       username: root
       password: 123456
       type: com.alibaba.druid.pool.DruidDataSource
       driver-class-name: com.mysql.jdbc.Driver
       filters: stat
       maxActive: 20
       initialSize: 1
       maxWait: 60000
       minIdle: 1
       timeBetweenEvictionRunsMillis: 60000
       minEvictableIdleTimeMillis: 300000
       validationQuery: select 'x'
       testWhileIdle: true
       testOnBorrow: false
       testOnReturn: false
       poolPreparedStatements: true
       maxOpenPreparedStatements: 20
    ##activemq连接信息
activemq:
   broker-url: tcp://localhost:61616
   in-memory: true
   pool:
     enabled: false
##队列
messages:
    queue: messages_queue

解决如下

原本activemq 没有在spring.后面直接在前面了,与spring同级了

解决后配置如下

server:
 port: 8762
#    context-path: /memeber
eureka:
 client:
   service-url:
     defaultZone: http://localhost:8761/eureka/
spring:
   application:
       name: member
   redis:
       host: 127.0.0.1
       password: 123456
       port: 6379
       pool:
           max-idle: 100
           min-idle: 1
           max-active: 1000
           max-wait: -1
   datasource:
       name: test1
       url: jdbc:mysql://127.0.0.1:3306/dandan-member
       username: root
       password: 123456
       type: com.alibaba.druid.pool.DruidDataSource
       driver-class-name: com.mysql.jdbc.Driver
       filters: stat
       maxActive: 20
       initialSize: 1
       maxWait: 60000
       minIdle: 1
       timeBetweenEvictionRunsMillis: 60000
       minEvictableIdleTimeMillis: 300000
       validationQuery: select 'x'
       testWhileIdle: true
       testOnBorrow: false
       testOnReturn: false
       poolPreparedStatements: true
       maxOpenPreparedStatements: 20
    ##activemq连接信息
   activemq:
       broker-url: tcp://localhost:61616
       in-memory: true
       pool:
          enabled: false
##队列
messages:
    queue: messages_queue

建议。yml缩进要四个字节。一个字节不容易分辨

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

相关文章

  • 在springboot中实现个别bean懒加载的操作

    在springboot中实现个别bean懒加载的操作

    这篇文章主要介绍了在springboot中实现个别bean懒加载的操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
    2020-10-10
  • Springcloud Nacos基本操作代码实例

    Springcloud Nacos基本操作代码实例

    这篇文章主要介绍了Springcloud Nacos基本操作代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
    2020-12-12
  • Spring Cloud Gateway Hystrix fallback获取异常信息的处理

    Spring Cloud Gateway Hystrix fallback获取异常信息的处理

    这篇文章主要介绍了Spring Cloud Gateway Hystrix fallback获取异常信息的处理方式,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
    2021-07-07
  • springboot大文件上传、分片上传、断点续传、秒传的实现

    springboot大文件上传、分片上传、断点续传、秒传的实现

    本文主要介绍了springboot大文件上传、分片上传、断点续传、秒传的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
    2022-07-07
  • java实现点赞功能

    java实现点赞功能

    这篇文章主要为大家详细介绍了java实现点赞功能,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
    2022-08-08
  • Java实现将文件或者文件夹压缩成zip的详细代码

    Java实现将文件或者文件夹压缩成zip的详细代码

    这篇文章主要介绍了Java实现将文件或者文件夹压缩成zip的详细代码,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友可以参考下
    2021-11-11
  • Java实现的求逆矩阵算法示例

    Java实现的求逆矩阵算法示例

    这篇文章主要介绍了Java实现的求逆矩阵算法,涉及java基于数组的矩阵遍历与运算相关操作技巧,需要的朋友可以参考下
    2017-09-09
  • springboot接口多实现类选择性注入解决方案

    springboot接口多实现类选择性注入解决方案

    这篇文章主要为大家介绍了springboot接口多实现类选择性注入解决方案的四种方式,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步
    2022-03-03
  • java 类加载机制和反射详解及实例代码

    java 类加载机制和反射详解及实例代码

    这篇文章主要介绍了java 类加载机制和反射详解及实例代码的相关资料,需要的朋友可以参考下
    2017-03-03
  • Java SE之了解泛型

    Java SE之了解泛型

    这篇文章主要介绍了Java SE之了解泛型,文章内容详细,简单易懂,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
    2023-01-01

最新评论