开发者社区 > 云原生 > 正文

RocketMQ与SpringBoot的集成无法启动

spring-boot-starter-parent

org.springframework.boot spring-boot-starter-parent 2.1.3.RELEASE

rocketmq的maven依赖

org.apache.rocketmq rocketmq-spring-boot-starter 2.2.0

org.apache.rocketmq rocketmq-client 4.8.0 报错提示

2021-02-14 21:26:32.369 WARN 6356 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userService': Unsatisfied dependency expressed through field 'rocketMQTemplate'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.apache.rocketmq.spring.core.RocketMQTemplate' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 2021-02-14 21:26:32.369 INFO 6356 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated... 2021-02-14 21:26:32.379 INFO 6356 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed. 2021-02-14 21:26:32.379 INFO 6356 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 2021-02-14 21:26:32.389 INFO 6356 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2021-02-14 21:26:32.409 INFO 6356 --- [ main] ConditionEvaluationReportLoggingListener :

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2021-02-14 21:26:32.529 ERROR 6356 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :

Field rocketMQTemplate in com.tanhua.sso.service.UserService required a bean of type 'org.apache.rocketmq.spring.core.RocketMQTemplate' 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 'rocketMQTemplate' in 'RocketMQAutoConfiguration' not loaded because AnyNestedCondition 0 matched 2 did not; NestedCondition on RocketMQAutoConfiguration.ProducerOrConsumerPropertyCondition.DefaultLitePullConsumerExistsCondition @ConditionalOnBean (types: org.apache.rocketmq.client.consumer.DefaultLitePullConsumer; SearchStrategy: all) did not find any beans of type org.apache.rocketmq.client.consumer.DefaultLitePullConsumer; NestedCondition on RocketMQAutoConfiguration.ProducerOrConsumerPropertyCondition.DefaultMQProducerExistsCondition @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 entries above or defining a bean of type 'org.apache.rocketmq.spring.core.RocketMQTemplate' in your configuration.

并且提问,rocketmq与redis是否有版本冲突或者依赖冲突. redis与rocketmq一起使用导致了redis获取key值需要一分钟左右才能获取到

原提问者GitHub用户Elgin-xj

展开
收起
芬奇福贵 2023-05-26 11:08:52 549 0
1 条回答
写回答
取消 提交回答
  • 看上去是 RocketMQTemplate 没有完成配置导致的,可以参考https://github.com/apache/rocketmq-spring/wiki 配置一下,另外rocketmq-spring 跟redis 是没有冲突的

    原回答者GitHub用户duhenglucky

    2023-05-26 17:25:20
    赞同 展开评论 打赏

阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。

相关产品

  • 云消息队列 MQ
  • 相关电子书

    更多
    阿里邮箱—安全高效集成 立即下载
    集成智能接入网关APP:优化企业级移动办公网络 立即下载
    云效助力企业集成安全到DevOps中 立即下载