1.导包
2.添加约束
3.开启注解管理事务
<!-- 开启使用注解管理事务 -->
<tx:annotation-driven/>
即可
4.在程序中使用注解
@Transactional(isolation = Isolation.REPEATABLE_READ, propagation = Propagation.REQUIRED,readOnly = false)
public void transfer(Integer from, Integer to, Double money) {
}
如果方法过多,则在类名上添加即可!
如果某个方法需要改变,在方法上声明新的属性即可!