首页 > 编程语言 > 详细

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

时间:2016-05-26 02:04:37      阅读:477      评论:0      收藏:0      [点我收藏+]

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/

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

原文:http://fanshuyao.iteye.com/blog/2300350

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!