1、首先在启动类加上
@EnableTransactionManagement(proxyTargetClass = true) 注:proxyTargetClass默认为false,springboot的事务是以 JDK dynamic proxy 实现的。我不加之前启动报错
Action:
Consider injecting the bean as one of its interfaces or forcing the use of CGLib-based proxies by setting proxyTargetClass=true on @EnableAsync and/or @EnableCaching.
2、启动类中加上以下代码,注入 DataSourceTransactionManager 实例
@Bean
public PlatformTransactionManager txManager(DataSource dataSource) {
return new DataSourceTransactionManager(dataSource);
}版权声明:本文为qq_32919085原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。