Spring5测试声明式事务管理(注解方式)出现的问题
org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named ‘accountServiceImpl’ is expected to be of type ‘com.itcast.service.impl.AccountServiceImpl’ but was actually of type 'com.sun.proxy.$Proxy18’
问题前的各项代码
配置文件
测试代码
事务类代码
解决问题
看文章发现配置文件中开启事物注解少加了proxy-target-class="true"
proxy-target-class属性值决定是基于接口的还是基于类的代理被创建。首先说明下proxy-target-class="true"和proxy-target-class="false"的区别,为true则是基于类的代理将起作用(需要cglib库),为false或者省略这个属性,则标准的JDK 基于接口的代理将起作用。