遇到factory.BeanNotOfRequiredTypeException Bean named xxx is expected tobe of type

遇到的錯誤

org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named ‘userServiceImpl’ is expected to be of type ‘com.huliyong.service.impl.UserServiceImpl’ but was actually of type ‘com.sun.proxy.$Proxy10’

UserServiceImpl userService = applicationContext.getBean("userServiceImpl", UserServiceImpl.class);

百度排查之後  發現是的原因是  aop 的動態代理的是一個接口  但是我寫的是一個類
 修改如下就可以了 
UserService userService = (UserService) applicationContext.getBean("userServiceImpl");


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章