spring使用xml配置事务(一次配置,多次使用)
下面使用spring.xml进行配置事务:(注解和xml同时注入时优先使用注解)
可以发现在配置需要事务的方法时使用通配符 *,这样会使指定格式的方法注入事务,而不是指定格式的方法则不会启动事务。
<aop:config>
<aop:pointcut id="transactionCut" expression="execution(* cn.cdulm.service.impl.*.*(..))"/>
aop:config>
<tx:advice>
<tx:attributes>
<tx:method name="add*"/>
<tx:method name="update*"/>
<tx:method name="delete*"/>
<tx:method name="get*"/>
<tx:method name="select*"/>
tx:attributes>
tx:advice>