目录
注解我们经常会用到,或者在jdk源码中也会看到,例如: @Deprecated
以及我们在spring或者springboot中经常用到@Controller、@Service、@Repository、@Entity等注解。








1)在applicationContext_service.xml文件中添加事务管理器
- <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
-
- <property name="dataSource" ref="dataSource">property>
- bean>
2)在applicationContext_service.xml文件中添加事务的注解驱动
<tx:annotation-driven transaction-manager="transactionManager">tx:annotation-driven>
3)在业务逻辑的实现类上添加注解@Transactional(propagation = Propagation.REQUIRED)
REQUIRED表示增删改操作时必须添加的事务传播特性



@Transactional(propagation = Propagation.REQUIRED,//事务的传播特性
noRollbackForClassName = "ArithmeticException", //指定发生什么异常不回滚,使用的是异常的名称
noRollbackFor = ArithmeticException.class,//指定发生什么异常不回滚,使用的是异常的类型
rollbackForClassName = "",//指定发生什么异常必须回滚
rollbackFor = ArithmeticException.class,//指定发生什么异常必须回滚
timeout = -1, //连接超时设置,默认值是-1,表示永不超时
readOnly = false, //默认是false,如果是查询操作,必须设置为true.
isolation = Isolation.DEFAULT//使用数据库自已的隔离级别
)
