zoukankan      html  css  js  c++  java
  • 问题排查之'org.apache.rocketmq.spring.starter.core.RocketMQTemplate' that could not be found.- Bean method 'rocketMQTemplate' in 'RocketMQAutoConfiguration' not loaded.

    背景

    今天将一个SpringBoot项目的配置参数从原有的.yml文件迁移到Apollo后,启动报错“Bean method 'rocketMQTemplate' in 'RocketMQAutoConfiguration' not loaded because @ConditionalOnBean (types: org.apache.rocketmq.client.producer.DefaultMQProducer; SearchStrategy: all) did not find any beans of type org.apache.rocketmq.client.producer.DefaultMQProducer”。花了两个小时才最终搞清楚,原因是缺少了配置项 spring.rocketmq.producer.group 从而导致无法成功创建RocketMQAutoConfiguration这个Bean,从而导致一连串对此有依赖的Bean无法创建成功。

    排查过程

    启动的错误日志

    2019-04-02 15:21:33.689  WARN 17516 --- [           main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'myServiceAImpl': Unsatisfied dependency expressed through field 'myServiceBImpl'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'myServiceAImpl': Unsatisfied dependency expressed through field 'rocketMQTemplate'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.apache.rocketmq.spring.starter.core.RocketMQTemplate' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
    2019-04-02 15:21:33.692  INFO 17516 --- [           main] com.alibaba.druid.pool.DruidDataSource   : {dataSource-1} closed
    2019-04-02 15:21:33.693  INFO 17516 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService
    2019-04-02 15:21:33.693  INFO 17516 --- [           main] f.a.ReferenceAnnotationBeanPostProcessor : class com.alibaba.dubbo.config.spring.beans.factory.annotation.ReferenceAnnotationBeanPostProcessor was destroying!
    2019-04-02 15:21:33.702  INFO 17516 --- [           main] ConditionEvaluationReportLoggingListener : 
    
    Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
    2019-04-02 15:21:33.842 ERROR 17516 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 
    
    ***************************
    APPLICATION FAILED TO START
    ***************************
    
    Description:
    
    Field rocketMQTemplate in net.yourpackage.myServiceBImpl required a bean of type 'org.apache.rocketmq.spring.starter.core.RocketMQTemplate' that could not be found.
    	- Bean method 'rocketMQTemplate' in 'RocketMQAutoConfiguration' not loaded because @ConditionalOnBean (types: org.apache.rocketmq.client.producer.DefaultMQProducer; SearchStrategy: all) did not find any beans of type org.apache.rocketmq.client.producer.DefaultMQProducer
    
    
    Action:
    
    Consider revisiting the conditions above or defining a bean of type 'org.apache.rocketmq.spring.starter.core.RocketMQTemplate' in your configuration.

    问题原因

    从上图中可以看到RocketMQAutoConfiguration中的mqProducer方法会根据配置参数来创建DefaultMQProducer,其中有两个必要的参数
    • spring.rocketmq.nameServer
    • spring.rocketmq.producer.group
    在重新检查了一遍配置文件后发现,的确是因为漏掉了spring.rocketmq.producer.group,将其加上之后便可以成功启动项目了。

  • 相关阅读:
    所有的工作目录 都要svn_开头,并且要进行svn同步,你能保证你不删除,你保证不了非你!
    火狐删除配置文件 会删除目录下所有文件 切记不要把配置文件建立在桌面 恢复软件:易我数据恢复向导 9.0 DiskGenius500
    谷歌全屏脚本 start chrome.exe --kiosk http://www.baidu.com
    bat2exe 就是这么简单 白研究半天VC++了
    火狐加载用户配置文件 "C:XXXMozilla Firefoxfirefox.exe" http://192.168.1.1:8080 -profile ../kkk
    https://quotefancy.com/ 经典句子(英语) 真是特别好~
    (function(){})() 立即执行函数
    jekyll 将纯文本转化为静态网站和博客 静态网站生成器
    vue 发布build 本地设置 相对路径 两个地方 一个根目录用./ css文件里面用../../ 【也不好用,还是得手改】
    iview构建 初始化的时候不要装ESlint 太烦人了
  • 原文地址:https://www.cnblogs.com/lingyejun/p/10657346.html
Copyright © 2011-2022 走看看