由于初学SPRING,对配置不太深入,所以想请教各位
(1):我用了<tx:annotation-driven transaction-manager="txManager"/>
(2)<!-- 那些类使用事务 -->
<aop:config>
<aop:pointcut id="point-cut" expression="execution(* com.wlh.spring.manager.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="point-cut"/>
</aop:config>
(1)和(2)有什么区别呢?
(1)我试过了好象也可以在任何地方用的,那么既然有了(1)了为什么还要有(2)呢,这两者到底有什么不同呢?哪个更强大呢,有了(2)还要不要(1)呢
<!-- 配置事务传播特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionMgr">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice> 这个又是指什么意思呢?难道前面的事务配置还不包括这些add,insert,del等语句吗?蒙!!蒙啊!谁来救我啊!!!
(1):我用了<tx:annotation-driven transaction-manager="txManager"/>
(2)<!-- 那些类使用事务 -->
<aop:config>
<aop:pointcut id="point-cut" expression="execution(* com.wlh.spring.manager.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="point-cut"/>
</aop:config>
(1)和(2)有什么区别呢?
(1)我试过了好象也可以在任何地方用的,那么既然有了(1)了为什么还要有(2)呢,这两者到底有什么不同呢?哪个更强大呢,有了(2)还要不要(1)呢
<!-- 配置事务传播特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionMgr">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice> 这个又是指什么意思呢?难道前面的事务配置还不包括这些add,insert,del等语句吗?蒙!!蒙啊!谁来救我啊!!!
<aop:config>
<aop:pointcut id="point-cut" expression="execution(* com.wlh.spring.manager.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="point-cut"/>
</aop:config>
____________________________________________________________________
这些事spring对AOP(面向切面编程)的一些配置.
________________________________________________
<!-- 配置事务传播特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionMgr">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
____________________________________________________
这个是spring对事务控制的配置信息,也就是说,在spring中,对增删改做一个事务的处理.
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
这个表示运行规则是先运行还是后运行
还没说 <tx:annotation-driven transaction-manager="txManager"/>
和
<aop:config>
<aop:pointcut id="point-cut" expression="execution(* com.wlh.spring.manager.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="point-cut"/>
</aop:config>
有什么区别呢?
哪位高手来解答下啊
(2)是另一种配置方法,纯XML配置,以那几个add,del,update开头的方法,AOP会被拦截从而对方法加入事务管里你,可以看看有关Spring AOP的知识就容易明白了。其实效果一样,实现手法不同:)