Bean named '' must be of type [], but was actually of type [$Proxy16]
在用junit测试dao接口时,出现以下的错误
Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'userDao' must be of type [com.changetech.dao.impl.UserDaoImpl], but was actually of type [$Proxy16]
最后经过仔细检查,错误原因如下:
@Resource(name="userDao")
protected UserDaoImpl userDao;
public void setUserDao(UserDaoImpl userDao) {
this.userDao = userDao;
}
原来在定义Dao时,没有用接口,而直接使用的是Dao的实现类,改为如下:
@Resource(name="userDao")
protected IUserDao userDao;
public void setUserDao(IUserDao userDao) {
this.userDao = userDao;
}
问题得到了解决
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦