成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

SpringBoot注解事務(wù)聲明式事務(wù)的方式-創(chuàng)新互聯(lián)

 springboot 對新人來說可能上手比springmvc要快,但是對于各位從springmvc轉(zhuǎn)戰(zhàn)到springboot的話,有些地方還需要適應(yīng)下,尤其是xml配置。我個人是比較喜歡注解➕xml是因為看著方便,查找方便,清晰明了。但是xml完全可以使用注解代替,今天就扒一扒springboot中事務(wù)使用注解的玩法。

創(chuàng)新互聯(lián)公司專注于永定企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站建設(shè),商城網(wǎng)站制作。永定網(wǎng)站建設(shè)公司,為永定等地區(qū)提供建站服務(wù)。全流程定制設(shè)計,專業(yè)設(shè)計,全程項目跟蹤,創(chuàng)新互聯(lián)公司專業(yè)和態(tài)度為您提供的服務(wù)

  springboot的事務(wù)也主要分為兩大類,一是xml聲明式事務(wù),二是注解事務(wù),注解事務(wù)也可以實現(xiàn)類似聲明式事務(wù)的方法,關(guān)于注解聲明式事務(wù),目前網(wǎng)上搜索不到合適的資料,所以在這里,我將自己查找和總結(jié)的幾個方法寫到這里,大家共同探討

springboot 之 xml事務(wù)

      可以使用 @ImportResource("classpath:transaction.xml") 引入該xml的配置,xml的配置如下

<?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:aop="http://www.springframework.org/schema/aop"
  xmlns:tx="http://www.springframework.org/schema/tx"
  xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop.xsd">
  <bean id="txManager"
    class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource" ></property>
  </bean>
  <tx:advice id="cftxAdvice" transaction-manager="txManager">
    <tx:attributes>
      <tx:method name="query*" propagation="SUPPORTS" read-only="true" ></tx:method>
      <tx:method name="get*" propagation="SUPPORTS" read-only="true" ></tx:method>
      <tx:method name="select*" propagation="SUPPORTS" read-only="true" ></tx:method>
      <tx:method name="*" propagation="REQUIRED" rollback-for="Exception" ></tx:method>
    </tx:attributes>
  </tx:advice>
   <aop:config>
    <aop:pointcut id="allManagerMethod" expression="execution (* com.exmaple.fm..service.*.*(..))" />
    <aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod" order="0" />
  </aop:config>
</beans>

網(wǎng)站欄目:SpringBoot注解事務(wù)聲明式事務(wù)的方式-創(chuàng)新互聯(lián)
當前網(wǎng)址:http://jinyejixie.com/article48/jshep.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供軟件開發(fā)、營銷型網(wǎng)站建設(shè)、靜態(tài)網(wǎng)站、自適應(yīng)網(wǎng)站、關(guān)鍵詞優(yōu)化、網(wǎng)頁設(shè)計公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運營
临洮县| 色达县| 文登市| 喀喇沁旗| 青浦区| 奉贤区| 太原市| 新沂市| 建昌县| 开鲁县| 苗栗市| 鹿邑县| 育儿| 英德市| 青冈县| 盐津县| 漳平市| 玉门市| 安福县| 新竹县| 临泉县| 策勒县| 景德镇市| 古浪县| 河北区| 崇明县| 乌兰县| 嘉兴市| 台东市| 南木林县| 乾安县| 新建县| 惠东县| 年辖:市辖区| 临漳县| 睢宁县| 永新县| 徐闻县| 新乡县| 磐石市| 玉龙|