由于初学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.   

    我的资源里有本spring参考手册,介绍的不错。有需要的朋友可以去看看
      

  2.   

    add  del update 指的是你上面配置文件中 com.wlh.spring.manager类中的方法中 以add  del update命名开头的方法用到了 事物
      

  3.   

    (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> 
    ____________________________________________________________________
    这些事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中,对增删改做一个事务的处理.
      

  4.   

    <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>  
    这个表示运行规则是先运行还是后运行
      

  5.   

    还有谁了解的更详细的吗
    还没说 <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>  
    有什么区别呢? 
    哪位高手来解答下啊
      

  6.   

    (1)是在需要事务的方法上用 @Transactional标识,然后在XML中用(1)中那样声明就行了,意思是告诉程序用使用 @Transactional标识的方法是需要事务的。
    (2)是另一种配置方法,纯XML配置,以那几个add,del,update开头的方法,AOP会被拦截从而对方法加入事务管里你,可以看看有关Spring AOP的知识就容易明白了。其实效果一样,实现手法不同:)