《SpringBoot2.X心法总纲》spring
启动类上添加注解@EnableTransactionManagement,默认开启事务,注解事务管理,等同于xml配置方式的 <tx:annotation-driven />spring-boot
接下来就能够直接在service方法上添加@Transactional就能够了spa
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> <version>2.0.3.RELEASE</version> </dependency>
不引入这种依赖的话,不能找到@EnableTransactionManagement注解的呦。.net
默认@Transacation就行,可是特别需求须要更改参数级别3d
这是@Transactional 里面的参数,能够根据公司或者场景选择因此要的事物级别和类型。xml