zoukankan      html  css  js  c++  java
  • Spring声明式事务(xml配置事务方式)

    Spring声明式事务(xml配置事务方式)

    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.

    蕃薯耀 2016年5月24日 10:12:13 星期二

    http://fanshuyao.iteye.com/

    xlm配置如下:

    <!-- 启用事务注解 -->
    	<!-- 
    		Spring事务默认只能对运行时异常(RuntimeException)进行回滚,
    		不会对Exception进行回滚。
    		如果需要指定其他异常,则需要配置:rollbackFor=Exception.class
    	 -->
    	 <!-- 注解事务 -->
    	<!-- <tx:annotation-driven transaction-manager="transactionManager"/> -->
    	
    	<!-- xml配置事务属性 -->
    	<tx:advice id="txAdvice" transaction-manager="transactionManager">
    		<tx:attributes>
    			<tx:method name="get*" read-only="true" isolation="READ_COMMITTED"/>
    			<tx:method name="query*" read-only="true" isolation="READ_COMMITTED"/>
    			<!-- <tx:method name="find*" read-only="true" isolation="READ_COMMITTED"/> -->
    			<!-- <tx:method name="search*" read-only="true" isolation="READ_COMMITTED"/> -->
    			<!-- <tx:method name="list*" read-only="true" isolation="READ_COMMITTED"/> -->
    			<tx:method name="*"/>
    		</tx:attributes>
    	</tx:advice>
    	
    	
    	<aop:config>
    		<!-- 配置事务切点 -->
    		<aop:pointcut expression="execution(* com.lqy.spring.iwx.service.*.*(..))" id="txPointcut"/>
    		
    		<!-- 关联事务属性及切点 -->
    		<aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut"/>
    	</aop:config>

    注意:

    当事务切点配置成这样时:

    <!-- 配置事务切点 -->
    <aop:pointcut expression="execution(* com.lqy.spring.iwx.service.impl.*(..))" id="txPointcut"/>

     即expression中红色标记的地方

    expression="execution(* com.lqy.spring.iwx.service.impl.*(..))",

    配置成这样的话,就会在此处报错:

    <!-- 关联事务属性及切点 -->
    <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut"/

    Pointcut is malformed: warning no match for this type name: com.lqy.spring.iwx.service.impl [Xlint:invalidAbsoluteTypeName]

    如果把红色的impl配置成 * ,则没有报错,运行也正常。不知道是什么原因,暂时记录。

    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.

    蕃薯耀 2016年5月24日 10:12:13 星期二

    http://fanshuyao.iteye.com/

  • 相关阅读:
    数据库事务与锁详解
    数据库:Mysql中“select ... for update”排他锁分析
    PHP之十六个魔术方法详解
    常见分布式缓存问题
    关于UIView的autoresizingMask属性的研究【转】
    WWDC2014之iOS使用动态库 framework【转】
    Android.mk的用法和基础【转】
    iOS 利用 framework 进行动态更新
    cocos2d-x + Lua接入iOS原生SDK的实现方案[转]
    lua绑定c++的时候常见得错误
  • 原文地址:https://www.cnblogs.com/fanshuyao/p/6227129.html
Copyright © 2011-2022 走看看