记得要配置在spring容器中
<!--配置声明式事物-->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="datasource"/>
</bean>
<!--结合AOP实现织入-->
<!--配置事物的通知:-->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<!--给哪个方法配置事物-->
<!--配置事物的传播特性 new-->
<tx:attributes>
<tx:method name="add" propagation="REQUIRED"/>
<tx:method name="delete" propagation="REQUIRED"/>
<tx:method name="update" propagation="REQUIRED"/>
<tx:method name="query" read-only="true"/>
<tx:method name="*"/> //就写这一个就行了,为了复习
</tx:attributes>
<!--配置事物切入-->
<!--配置事物切入点-->
<aop:config>
<aop:pointcut id="txPointCut" expression="execution(* com.wen.mapper.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="txPointCut"/>
</aop:config>
</tx:advice>