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

歡迎訪問 生活随笔!

生活随笔

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

javascript

Spring-学习笔记10【Spring事务控制】

發(fā)布時(shí)間:2024/9/30 javascript 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Spring-学习笔记10【Spring事务控制】 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
  • Java后端 學(xué)習(xí)路線 筆記匯總表【黑馬程序員】
  • Spring-學(xué)習(xí)筆記01【Spring框架簡(jiǎn)介】【day01】
  • Spring-學(xué)習(xí)筆記02【程序間耦合】
  • Spring-學(xué)習(xí)筆記03【Spring的IOC和DI】
  • Spring-學(xué)習(xí)筆記04【Spring的常用注解】【day02】day02資料_dbutils
  • Spring-學(xué)習(xí)筆記05【基于XML的IOC的案例】
  • Spring-學(xué)習(xí)筆記06【Spring的新注解】
  • Spring-學(xué)習(xí)筆記07【銀行轉(zhuǎn)賬案例】【day03】
  • Spring-學(xué)習(xí)筆記08【面向切面編程AOP】
  • Spring-學(xué)習(xí)筆記09【JdbcTemplate的基本使用】【day04】
  • Spring-學(xué)習(xí)筆記10【Spring事務(wù)控制】
  • 目錄

    01 基于XML的AOP實(shí)現(xiàn)事務(wù)控制

    02 作業(yè)-基于注解的AOP實(shí)現(xiàn)事務(wù)控制及問題分析_上

    03 作業(yè)-基于注解的AOP實(shí)現(xiàn)事務(wù)控制及問題分析_下

    04 spring中事務(wù)控制的一組API

    05 spring事務(wù)控制的代碼準(zhǔn)備

    06 spring基于XML的聲明式事務(wù)控制-配置步驟

    06.1、bean.xml

    07 spring基于注解的聲明式事務(wù)控制

    08 spring基于純注解的聲明式事務(wù)控制

    09 spring編程式事務(wù)控制1-了解

    10 spring編程式事務(wù)控制2-了解

    11 spring5新特性的介紹

    11.1、Test.java


    01 基于XML的AOP實(shí)現(xiàn)事務(wù)控制

    02 作業(yè)-基于注解的AOP實(shí)現(xiàn)事務(wù)控制及問題分析_上

    03 作業(yè)-基于注解的AOP實(shí)現(xiàn)事務(wù)控制及問題分析_下

    注解AOP控制事務(wù)的問題分析

    04 spring中事務(wù)控制的一組API

    05 spring事務(wù)控制的代碼準(zhǔn)備

    06 spring基于XML的聲明式事務(wù)控制-配置步驟

    06.1、bean.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/beanshttp://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx.xsdhttp://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop.xsd"><!-- 配置業(yè)務(wù)層 --><bean id="accountService" class="com.itheima.service.impl.AccountServiceImpl"><property name="accountDao" ref="accountDao"></property></bean><!-- 配置賬戶的持久層 --><bean id="accountDao" class="com.itheima.dao.impl.AccountDaoImpl"><property name="dataSource" ref="dataSource"></property></bean><!-- 配置數(shù)據(jù)源 --><bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"><property name="driverClassName" value="com.mysql.jdbc.Driver"></property><property name="url" value="jdbc:mysql://localhost:3306/eesy"></property><property name="username" value="root"></property><property name="password" value="root"></property></bean><!-- spring中基于XML的聲明式事務(wù)控制配置步驟1、配置事務(wù)管理器2、配置事務(wù)的通知此時(shí)我們需要導(dǎo)入事務(wù)的約束 tx名稱空間和約束,同時(shí)也需要aop的使用tx:advice標(biāo)簽配置事務(wù)通知屬性:id:給事務(wù)通知起一個(gè)唯一標(biāo)識(shí)transaction-manager:給事務(wù)通知提供一個(gè)事務(wù)管理器引用3、配置AOP中的通用切入點(diǎn)表達(dá)式4、建立事務(wù)通知和切入點(diǎn)表達(dá)式的對(duì)應(yīng)關(guān)系5、配置事務(wù)的屬性是在事務(wù)的通知tx:advice標(biāo)簽的內(nèi)部 --><!-- 配置事務(wù)管理器 --><bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"><property name="dataSource" ref="dataSource"></property></bean><!-- 配置事務(wù)的通知 --><tx:advice id="txAdvice" transaction-manager="transactionManager"><!-- 配置事務(wù)的屬性isolation:用于指定事務(wù)的隔離級(jí)別。默認(rèn)值是DEFAULT,表示使用數(shù)據(jù)庫(kù)的默認(rèn)隔離級(jí)別。propagation:用于指定事務(wù)的傳播行為。默認(rèn)值是REQUIRED,表示一定會(huì)有事務(wù),增刪改的選擇。查詢方法可以選擇SUPPORTS。read-only:用于指定事務(wù)是否只讀。只有查詢方法才能設(shè)置為true。默認(rèn)值是false,表示讀寫。timeout:用于指定事務(wù)的超時(shí)時(shí)間,默認(rèn)值是-1,表示永不超時(shí)。如果指定了數(shù)值,以秒為單位。rollback-for:用于指定一個(gè)異常,當(dāng)產(chǎn)生該異常時(shí),事務(wù)回滾;產(chǎn)生其他異常時(shí),事務(wù)不回滾;沒有默認(rèn)值,表示任何異常都回滾。no-rollback-for:用于指定一個(gè)異常,當(dāng)產(chǎn)生該異常時(shí),事務(wù)不回滾,產(chǎn)生其他異常時(shí)事務(wù)回滾。沒有默認(rèn)值。表示任何異常都回滾。 --><tx:attributes><tx:method name="*" propagation="REQUIRED" read-only="false"/><tx:method name="find*" propagation="SUPPORTS" read-only="true"></tx:method></tx:attributes></tx:advice><!-- 配置aop --><aop:config><!-- 配置切入點(diǎn)表達(dá)式 --><aop:pointcut id="pt1" expression="execution(* com.itheima.service.impl.*.*(..))"></aop:pointcut><!-- 建立切入點(diǎn)表達(dá)式和事務(wù)通知的對(duì)應(yīng)關(guān)系 --><aop:advisor advice-ref="txAdvice" pointcut-ref="pt1"></aop:advisor></aop:config> </beans>

    07 spring基于注解的聲明式事務(wù)控制

    08 spring基于純注解的聲明式事務(wù)控制

    09 spring編程式事務(wù)控制1-了解

    10 spring編程式事務(wù)控制2-了解

    編程式事務(wù)

    11 spring5新特性的介紹

    11.1、Test.java

    jdk8和Jdk7的對(duì)比 package com.itheima.test;import java.lang.reflect.Method;/*** @author 黑馬程序員* @Company http://www.ithiema.com* @Version 1.0*/ public class Test {//循環(huán)次數(shù)定義:10億次private static final int loopCnt = 1000 * 1000 * 1000;public static void main(String[] args) throws Exception {//輸出jdk的版本System.out.println("java.version=" + System.getProperty("java.version"));t1();t2();t3();}// 每次重新生成對(duì)象public static void t1() {long s = System.currentTimeMillis();for (int i = 0; i < loopCnt; i++) {Person p = new Person();p.setAge(31);}long e = System.currentTimeMillis();System.out.println("循環(huán)10億次創(chuàng)建對(duì)象的時(shí)間:" + (e - s));}// 同一個(gè)對(duì)象public static void t2() {long s = System.currentTimeMillis();Person p = new Person();for (int i = 0; i < loopCnt; i++) {p.setAge(32);}long e = System.currentTimeMillis();System.out.println("循環(huán)10億次給同一對(duì)象賦值的時(shí)間: " + (e - s));}// 使用反射創(chuàng)建對(duì)象public static void t3() throws Exception {long s = System.currentTimeMillis();Class<Person> c = Person.class;Person p = c.newInstance();Method m = c.getMethod("setAge", Integer.class);for (int i = 0; i < loopCnt; i++) {m.invoke(p, 33);}long e = System.currentTimeMillis();System.out.println("循環(huán)10億次反射創(chuàng)建對(duì)象的時(shí)間:" + (e - s));}static class Person {private int age = 20;public int getAge() {return age;}public void setAge(Integer age) {this.age = age;}} } jdbctemplate和queryrunner的區(qū)別

    總結(jié)

    以上是生活随笔為你收集整理的Spring-学习笔记10【Spring事务控制】的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

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