问题描述:
项目启动报错:The bean ‘xxxServiceImpl’ could not be injected as a ‘cn.xxxx.service.xxxServiceImpl’ because it is a JDK dynamic proxy that implements:
大概意思是默认采用jdk动态代理因为动态代理需要类实现接口,通过接口进行代理,但是我们通过 @Autowired 注解进行注入bean的时候采用了它的实现类而没有采用它的接口。
在配置文件中配置采用类代理也没有用。
解决方法:在启动类事务注解上添加proxyTargetClass=true,强迫事务使用CGLib代理方式。
@EnableTransactionManagement(proxyTargetClass=true)



