事物
=============================开启注解扫描=============================
<!--事务管理器类-->
<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<!--开启注解扫描-->
<context:component-scan base-package="com.juaner.spring.tx"/>
<!--注解方式实现事务-->
<tx:annotation-driven transaction-manager="txManager"/>
===============================使用注解==================================
@Transactional public void save(Student student){ this.studentDao.save(student); int i = 1/0; this.studentDao.save(student); }
===================================事物属性====================================
@Transactional(
readOnly = false, //读写事务
timeout = -1 , //事务的超时时间,-1为无限制
noRollbackFor = ArithmeticException.class, //遇到指定的异常不回滚
isolation = Isolation.DEFAULT, //事务的隔离级别,此处使用后端数据库的默认隔离级别
propagation = Propagation.REQUIRED //事务的传播行为
)