`

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;

}

问题得到了解决

分享到:
评论
1 楼 yulianyu 2013-11-27  
<aop:aspectj-autoproxy proxy-target-class="true"/>
自动代理的参数加入代理cglib的

相关推荐

Global site tag (gtag.js) - Google Analytics