Spring AOP 管理事务

    <aop:config proxy-target-class="true">
        <aop:pointcut expression="execution(* com.jikexueyuan.dao.impl.*.*(..))" id="cut"/>
        <aop:advisor advice-ref="defaultTransactionAdvice" pointcut-ref="cut"/>        
    </aop:config>
    
    <bean id="transactionManager"
        class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory" />
        <property name="dataSource" ref="datasource"></property>  
    </bean>
    <tx:advice transaction-manager="transactionManager" id="defaultTransactionAdvice">
             <tx:attributes>  
                  <tx:method name="add*" read-only="false"/> 
               <tx:method name="*"/>  
          </tx:attributes> 
    </tx:advice>

 

posted @ 2017-03-23 15:39  我们不该这样的  阅读(160)  评论(0编辑  收藏  举报