Springboot实现事务步骤
1.在启动类加上
@EnableTransactionManagement
2.在业务层方法上加
@Transactional(rollbackFor = Exception.class)
3.在逻辑上如果需要手动回滚则加入下代码
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@EnableTransactionManagement
@Transactional(rollbackFor = Exception.class)
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();