1. 在springboot中整合RabbitMq的过程中,遇到如下错误:(截取部分)

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'helloSender': Unsatisfied dependency expressed through field 'rabbitTemplate';..........

Caused by: java.lang.IllegalStateException: Failed to introspect Class [org.springframework.amqp.rabbit.core.RabbitTemplate] from ClassLoader [sun.misc.Launcher$AppClassLoader@4e0e2f2a]

Caused by: java.lang.ClassNotFoundException: com.rabbitmq.client.ConfirmCallback

控制台信息:

     

出现问题的代码行:

    @Autowired
private RabbitTemplate rabbitTemplate;

解决的过程:

(1)猜想应该是RabbitTemplate类没有加载,导致无法注入。看错误信息,要注入RabbitTemplate的bean实体,则是在RabbitAutoConfiguration的内部类中,如下图。

然后我在启动类中手动加入RabbitAutoConfiguration类,从而加载该bean。即在启动类中显示的注入bean:@EnableAutoConfiguration(exclude={RabbitAutoConfiguration.class})。

       

再重新启动。重新启动后报如下错误:Consider defining a bean of type 'org.springframework.amqp.rabbit.core.RabbitTemplate' in your configuration. 即:

依然没有解决,然后猜想应该不是这个原因。因为类中明明已经加载了该类也有这个bean,但就是不行

最终解决方法:

(2)在网上多次浏览其他类似的错误后,猜想可能是由于包的冲突所造成的。在pom.xml中引入了3.4.1版的amqp-client和spring-boot-starter-amqp,然后点进spring-boot-starter-amqp的包中,发现也引入了amqp-client,其版本是5.4.3。看来是由于包冲突引起的。

  将3.4.1版的amqp-client的注释掉,update项目,同时将上面的(1)中启动类的@EnableAutoConfiguration(exclude={RabbitAutoConfiguration.class})也注释。重新再启动,发现不再报错,成功解决。产生该问题的原因就是包冲突了。

Unsatisfied dependency expressed through field 'rabbitTemplate'错误总结的更多相关文章

  1. 错误: Error creating bean with name 'studentController': Unsatisfied dependency expressed through field 'studentServiceImpl';

    详细错误: 严重: Context initialization failed org.springframework.beans.factory.UnsatisfiedDependencyExcep ...

  2. 出错:Error creating bean with name 'studentServiceImpl': Unsatisfied dependency expressed through field 'studentMapper';

    详细错误: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with nam ...

  3. Error creating bean with name 'student': Unsatisfied dependency expressed through field 'teacher'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating

    有 有参构造但是没有无参构造...

  4. Redis——解决“org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'redisReferenceResolver': Unsatisfied dependency expressed through constructor parameter 0”

    错误栈: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ...

  5. spring异常Unsatisfied dependency expressed through constructor parameter 0

    异常信息: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with nam ...

  6. Android Studio中出现Gradle's dependency cache may be corrupt错误的解决办法

    起因 某次打开AS,提示升级AS,升级后,提示升级gradle,选择升级. 结果在升级gradle时耗时较久,没有耐心,点击停止升级gradle, 还是停在那里,然后关闭AS,还是没反应,启动任务管理 ...

  7. com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 's.areaname' in 'field list'错误

    在使用mybatis框架做查询的时候,出现了如下错误: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown colum ...

  8. No unique bean of type..... Unsatisfied dependency of type

    比如在XXXServiceImpl里面写了aa()方法给别的地方调用 但是自己又调用了自己 在开头写了 @Autowired Private XXX xxx; xxx.aa(); 这样重复调用自己的b ...

  9. Unknown column '字段名' in 'field list' 错误解决方案

    当后台报这个错误的时候,说明实体类中的字段名出错了,解决方案: 1,检查数据库中的字段名与实体类中的字段名是否一致,特别要注意单词字母, 2,检查数据库中的字段是否与实体类中的字段一致.比如数据库中没 ...

随机推荐

  1. oracle sqlldr导入数据和导入去除空格

    1.新建目录E:\load把需要导入的数据文件放到目录下面 这是我自己造的测试数据... 2.在文件下新建脚本文件 Load data infile 'E:\load\info.txt' into t ...

  2. Redis 底层数据结构之跳跃表

    文章参考 <Redis 设计与实现>黄建宏 Redis(2) 跳跃表 跳跃表 跳跃表 skiplist 是一种有序数据结构,它通过在每个节点中维持多个指向其他节点的指针,从而达到快速访问节 ...

  3. AcWing 237. 程序自动分析

    #include<bits/stdc++.h> using namespace std; const int N=1e6+5; int f[N*2],a[N],b[N],c[N],n,t, ...

  4. Spring-Redis缓存业务优化(通配符删除、两种自定义缓存时长)

    application.yml配置 spring:    cache:     type: REDIS     redis:       time-to-live: PT300S # 默认缓存秒数   ...

  5. MyBatis:Mybatis逆向工程问题记录

    近日我在搭建springboot+mybatis+mysql 的整合项目(自己测试玩)的时候用到了mybatis的逆向工程,来这里记录一下我的菜鸟编码过程 首先我在maven中引入这些依赖 <d ...

  6. SpringMVC(3)URL请求到Action的映射规则

    在SpringMVC(2)经典的HelloWorld实现我们展示了一个简单的get请求,并返回了一个简单的helloworld页面.本篇我们来学习如何来配置一个action的url映射规则. 在Spr ...

  7. Linux从头学03:如何告诉 CPU,代码段、数据段、栈段在内存中什么位置?

    作 者:道哥,10+年的嵌入式开发老兵. 公众号:[IOT物联网小镇],专注于:C/C++.Linux操作系统.应用程序设计.物联网.单片机和嵌入式开发等领域. 公众号回复[书籍],获取 Linux. ...

  8. mybatis复杂映射

    1. 类型名对应 当实体类与表中字段完全一致时,mapper文件里返回类型用resultType,否则要用resultMap,并且建立resultMap映射 package com.rf.domain ...

  9. 个人博客开发之blog-api 项目全局日志拦截记录

    前言 大型完善项目中肯定是需要一个全局日志拦截,记录每次接口访问相关信息,包括: 访问ip,访问设备,请求参数,响应结果,响应时间,开始请求时间,访问接口描述,访问的用户,接口地址,请求类型,便于项目 ...

  10. 计算机毕业设计选题大合集,含ssm,springboot,小程序,php,python

    1基于springboot医院急诊系统 2基于springboot校园闲置物品租售系统 3基于springboot校园闲置物品交易网站 4基于springboot图书网站 5基于springboot外 ...