报错信息:Bean named 'DeptServiceImplements' is expected to be of type 'com.cctv.service.imp.DeptServiceImplements' but was actually of type 'jdk.proxy2.$Proxy38'
简单的理解就是这里自动注入有问题.
错误注入:
正确注入:
我们可以知道,DeptService是一个接口,DeptServiceImplements是一个实现了DeptService的类(也可以理解是DeptService的子类),我们在之前都是通过@Autowired自动注解需要使用的类,但是如果出现了这种BeanNotOfRequiredTypeException错误,我们就得去修改注入,把原来注入的类改成其接口(父类),在图中就是把自动注入DeptServiceImplements改成DeptService接口.