多数据源时,一般会配置多个事务管理器

Spring编程式

第二种方式
不可能去同一个方法上写两个事务注解 不允许

SpringBoot 2.6.0之后禁止自己注入自己
本来可以自己注入自己去调用 (为什么要自己注入自己调用,AOP代理,类不是自己写的类)


最简单方式
引入
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>${version}</version>
</dependency>
@DSTrasactional 一个注解搞定