Bean named ‘userService‘ is expected to be of type ‘com.zkf.service.userServiecImpl‘ but[我的报错日常]
报错:
原因:getBean方法 第二个参数应该写的是接口,而不是它的实现类
(动态代理的是接口【记住使用框架都要用接口类型来引用实现类对象】)
代理类与被代理类都是UserService接口的实现类
新生成的代理类只能向上转型为接口类型,不能强转给同等级UserServiceImpl
说个多态的简单的例子
Animal的子类有Cat类、Dog类
你不能将Cat类强转成Dog类,只能将Cat类向上转成Animal类
解决方法:将userServiecImpl.class–>userServiec.class
Bean named ‘userService‘ is expected to be of type ‘com.zkf.service.userServiecImpl‘ but[我的报错日常]相关推荐
- SpringAOP实现报错Bean named ‘userServiceImpl‘ is expected to be of type ‘.....‘
问题 在练习SpringAOP过程中出现如下报错 Bean named 'userServiceImpl' is expected to be of type 'com.fjd.service.imp ...
- Bean named XXX is expected to be of type XXX but was actually of type 'com.sun.proxy.$Proxy28'
现象 运行Spring Web程序时报出错误 BeanNotOfRequiredTypeException: Bean named 'loginLogService' is expected to b ...
- 关于spring boot的Bean named ‘aaa‘ is expected to be of type ‘bbb‘ but was actually of type ‘bbb‘问题的解决方案
相信后端的同学在平时开发时都大多都使用到spring boot来开发,那么在使用bean工厂注册bean时说不定会遇到过Bean named 'aaa' is expected to be of ty ...
- Bean named ‘xxx‘ is expected to be of type ‘xxx‘ but was actually of type ‘zzzz‘
Bean named 'whiteListConfig' is expected to be of type 'java.lang.String' but was actually of type ' ...
- Bean named ‘Target‘ is expected to be of type ‘com.itheima.aop.Target‘ but was actually of type ‘com
这是一个接口实现方法 package com.itheima.aop;public class Target implements TargetInterface{public void save() ...
- Bean named ‘xxx‘ is expected to be of type ‘com.xxx.xxx‘ but was actually of type ‘com.xxx.xxx‘
// 图片报错的类别名 redisServiceImpl // 意思是别名 redisServiceImpl 已经被别的类使用了@Resourceprivate RedisUtil redisServ ...
- 遇到factory.BeanNotOfRequiredTypeException Bean named xxx is expected tobe of type
遇到的错误 org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'userServiceImpl' ...
- Bean named 'rateBoardService' is expected to be of but was actually of type 'com.sun.proxy.$Proxy69'
Bean named 'rateBoardService' is expected to be of type 'xxxx' 今天在写一个测试用例的时候遇到个Bug,提示语如下: 可以只看第一行 or ...
- Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'dao' is exp
异常信息: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with nam ...
最新文章
- MYSQL忘记登录密码
- Linux下command not found(以CentOS下没有telnet为例)
- 转:关于CCDISK的优化
- 吴恩达深度学习课程的漫画版来了!(漫画、视频、笔记都可以下载了!)
- 商城计价中心 - 从容应对复杂场景价格计算
- mysql必知必会学习笔记(一)
- Databricks文档03----Azure Databricks 创建
- 和我一起学CSLA.NET----创建业务对象2
- MySql8.0.15修改root密码
- 在线UML图设计 用例图 在线制图
- 职称计算机考试题库破解版2017,2017职称计算机考试题库及答案
- 从羽泉演唱会大数据看在线演出前景
- Spring系列:2021年Java春招面试经历,内容太过真实
- PG系列6-PostgreSQL的体系架构
- 微型计算机内存为16m,微型计算机的内存为16M,指的是其内存容量为()。
- 计算机准考证要打印多大的纸,税务证准考证打印纸张大小要求多大的?
- 开源真香 离线识别率高 Python 人脸识别系统
- 蒙特卡洛抽样电动汽车充电负荷
- 写给嵌入式程序员的循环冗余校验(CRC)算法入门引导
- GNSS说第(七)讲---自适应动态导航定位(八)---抗差自适应滤波