遇到的錯誤
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");