错误描述:Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named '****' is expected to be of type '****' but was actually of type 'com.sun.proxy.$Proxy**'
的解决方法。
我的controller里面的代码是:
@Autowired private UserServiceImpl userServiceImpl;
解决办法是将UserServiceImpl实现类改成 改成UserService接口,这样就行了。
解决之后的代码是:
@Autowired private UserService userServiceImpl;
具体原因是应该使用接口去接收代理对象,从而获取到代理对象。