日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 前端技术 > javascript >内容正文

javascript

Spring事务配置方式(一) 拦截器方式配置

發(fā)布時(shí)間:2023/12/1 javascript 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Spring事务配置方式(一) 拦截器方式配置 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

一、使用<tx:advice>和<aop:config>配置事務(wù)

<!-- 配置事務(wù)管理器 --><bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource" /></bean><!-- 注解方式配置事物 --><!-- <tx:annotation-driven transaction-manager="transactionManager" /> --><!-- 攔截器方式配置事物 --><tx:advice id="transactionAdvice" transaction-manager="transactionManager"><tx:attributes><tx:method name="add*" propagation="REQUIRED" /><tx:method name="insert*" propagation="REQUIRED" /><tx:method name="update*" propagation="REQUIRED" /><tx:method name="modify*" propagation="REQUIRED" /><tx:method name="delete*" propagation="REQUIRED" /><tx:method name="delAndRepair" propagation="REQUIRED" /><tx:method name="get*" propagation="SUPPORTS" /><tx:method name="find*" propagation="SUPPORTS" /><tx:method name="search*" propagation="SUPPORTS" /><tx:method name="*" propagation="SUPPORTS" /></tx:attributes></tx:advice><aop:config><aop:pointcut id="transactionPointcut" expression="execution(* com.fog.travel.service..*impl.*(..))" /><aop:advisor pointcut-ref="transactionPointcut" advice-ref="transactionAdvice" /></aop:config>

?

而對(duì)于<aop:config>具體解釋為:

表示com.fog.travel.service包下的所有方法為為事務(wù)管理。expression="execution(* com.fog.travel.service.impl.*.*(..))"這樣寫應(yīng)該就可以了 這是com.fog.travel.service..*impl包下所有的類的所有方法。。 第一個(gè)*代表所有的返回值類型 第二個(gè)*代表所有的類 第三個(gè)*代表類所有方法 最后一個(gè)..代表所有的參數(shù)。

?

  注意事項(xiàng):<beans>中要加入“xmlns:aop”的命名申明,并在“xsi:schemaLocation”中指定aop配置的schema的地址 ,才會(huì)正確的顯示tx標(biāo)簽

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

?

具體標(biāo)簽信息:

屬性是否必須默認(rèn)值描述
name? ?YES ?與事務(wù)屬性關(guān)聯(lián)的方法名。通配符(*)可以用來(lái)指定一批關(guān)聯(lián)到相同的事務(wù)屬性的方法。 如:'get*'、'handle*'、'on*Event'等等。
propagation NOREQUIRED事務(wù)傳播行為
isolation NO  DEFAULT事務(wù)隔離級(jí)別
timeout NO  -1事務(wù)超時(shí)的時(shí)間(以秒為單位)
read-only NO  false事務(wù)是否只讀?
rollback-for NO  ?將被觸發(fā)進(jìn)行回滾的 Exception(s);以逗號(hào)分開。 如:'com.foo.MyBusinessException,ServletException'
no-rollback-for NO?不 被觸發(fā)進(jìn)行回滾的 Exception(s);以逗號(hào)分開。 如:'com.foo.MyBusinessException

?

其他詳解:http://tonl.iteye.com/blog/1966075

轉(zhuǎn)載于:https://www.cnblogs.com/binbang/p/5063295.html

總結(jié)

以上是生活随笔為你收集整理的Spring事务配置方式(一) 拦截器方式配置的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。