声明式管理事务:基于AspectJ的xml方式

1.配置事物管理器

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

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

</bean>

2..配置事务的通知:(事务的增强

<tx:advice id="txAdvice"   transaction-manager="transactionManager">

<!--------propagation:事务的传播行为

             isolation:事务的隔离级别

             readonly:只读信息

             rollbackFor:发生哪些异常回滚------------>

<tx:method  name=''transfer'   propagation='REQUIRED'/>   //需要的方法

</tx:advice>

3.配置切面

<aop:config>

<!--配置切入点>

<aop :pointcut   expression=" execution(  *   cn.muke.spring.demo.accountservice+*(..)) " id="pointcut1">

<!-配置切面>

<.aop:advisor  advice-ref="txAdvice"  pointcut-ref="pointcut1"/>

</aop comfig>

猜你喜欢

转载自blog.csdn.net/libaowen609/article/details/82928417