Bean named '*' must be of type [*], but was actually of type [$Proxy16]

转自:http://niweiwei.iteye.com/blog/1547665

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;

}

问题得到了解决

posted @ 2016-03-29 17:44  GoQC  阅读(921)  评论(0)    收藏  举报