`
frank1998819
  • 浏览: 758413 次
  • 性别: Icon_minigender_1
  • 来自: 南京
文章分类
社区版块
存档分类

Bean named '*' must be of type [*], but was actually of type (转)

 
阅读更多


在用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;

}

问题得到了解决
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics