Spring的事务管理

第一步:注册事务管理器:

<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

      <property name="dataSource" ref="dataSource"/>

</bean>

 

第二步:注册事务模板类:

<bean id="transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate">

    <property name="transactionManager" ref="transactionManager"/>

</bean>

 

第三步:在service层注入模板类:

<bean id="TService" class="service.TServiceImpl">

    <property name="TDao" ref="TDao"/>

</bean>

 

<bean id="TDa0" class="dao.TDaoImpl">

    <property name="transactionTemplate" ref="transactionTemplate"/>

</bean>

第四步:在业务层代码上使用模板:

根据自己的项目来写实现

 该方法的特点:

* 代码量大。

原文地址:https://www.cnblogs.com/longlinxie/p/5628267.html