遇到的错误
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");