Spring 事务管理详解

本文详细介绍了Spring事务管理,包括事务的四大特性(ACID)、事务并发带来的问题及解决方案,以及编程式和声明式事务管理的实现,通过具体的转账示例展示了Spring如何处理事务。同时,文中还对比了不同事务管理方式的使用场景和优缺点。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

相信大家面试都经常会被问到框架相关的,或者有没有用过事务?那么看篇文章就对了。

1.什么是事务

       所谓事务是用户定义的一个数据库操作序列,这些操作要么全做,要么全不做,是一个不可分割的工作单位。

说白了就是要么一起成功要么一起失败。不存在一些成功一些失败。充分说明了事务的原子性

举个现实中最通俗易懂的栗子


以上就是我们经常会通过银行的转账系统来转账。如果没有事务,别人本来需要转账给你1000的 结果别人的账户里扣了1000 但是你的账户还是之前的0,你肯定会不开森不会同意的吧。事务的重要性就体现出来了,银行既要保证别人的利益又要保证你的利益。所以理解和使用事务还是非常重要的。尤其是金融行业。

2.事务的特性(简称ACID)

原子性 (Atomicity) :要么全做,要么全不做。

一致性 (Consistency) :说的是全部做,和全不做,这时数据库处于一致性,如果一个做,一个不做,就认为不一致。

隔离性(Isolation) :一个事务的执行不能被其他事务干扰,即一个事务的内部操作以及使用的数据对其他并发事务是隔离的。

持续性 (Durability) :一个事务一旦提交,它对数据库中数据的改变就应该是永久行的。、

 

3.事务并发操带来哪些问题

  3.1丢失修改

         两个事务T1和T2读入同一个数据并修改,T2提交的结果破坏了T1提交的结果,导致T1的修改被丢失。

  3.2不可重复读

         事务T1读取数据后,事务T2执行更新操作,使得T1无法再现前一次读到的结果。

  3.3读脏数据

        T1修改某一个数据并将其写回磁盘,事务T2读到T1修改之后的数据,这时T1由于某种原因被撤销,数据恢复到原来的值,T1读到的数据为脏数据。

  3.4幻读

       事务T1读取数据后,事务T2执行插入操作,T1再次读取,使T1出现了幻觉。

4.事务的API介绍

   4.1 事务管理器PlatformTransactionManager


spring为不同的持久化框架提供了不同的PlatformTransactionManager


   4.2 TransactionDefinition事务定义信息(隔离,传播,超时,只读)

       4.2.1 隔离级别

设置隔离级别可防止并发导致的问题。


如果选择DEFAULT则是数据库默认的隔离级别。

MySQL 默认REPEATABLE_READ

Oracle默认 READ_COMMITTED

  4.2.2 事务的传播行为


  4.2.3 TransactionStatus事务具体运作状态

void flush();冲洗数据库底层会话

boolean hasSavePoint();返回该事务是否有一个保存点

boolean isCompleted();返回事务是否提交或者回滚

boolean isNewTransaction();返回是否是一个新事务

boolean isRollbackOnly();判断这个事务是否已经设置了rollback-only。

void setRollbackOnly();设置这个事务rollback-only。

4.2.4 SavepointManager
 
事务回滚点管理接口,提供创建、释放回滚点,或者回滚到指定的回滚点。
 
 方法摘要:
 Object createSavepoint()
          Create a new savepoint.
          创建一个新的回滚点。
 void releaseSavepoint(Object savepoint)
          Explicitly release the given savepoint.
          释放一个给定的回滚点。
 void rollbackToSavepoint(Object savepoint)
          Roll back to the given savepoint.
          回滚到给定的回滚点。

5.转账示例

5.1 编程式事务管理

   5.1.1 创建数据库


5.1.2 Dao层

[java] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. public interface AccountDao {  
  2.   
  3.   
  4. /** 
  5. * @param out :转出账号 
  6. * @param money:转账金额 
  7. */  
  8. public void outMoney(String out,Double money);  
  9.   
  10. /** 
  11.  
  12. * @param in :转入账号 
  13. * @param money:转账金额 
  14. */  
  15. public void inMoney(String in,Double money);  
  16. }  
  17.   
  18.   
  19. public class AccountDaoImpl extends JdbcDaoSupport implements AccountDao {  
  20.   
  21.   
  22. /** 
  23. * @param out :转出账号 
  24. * @param money:转账金额 
  25. */  
  26. @Override  
  27. public void outMoney(String out, Double money) {  
  28. String sql = "update account set money = money-? where name = ?";  
  29. this.getJdbcTemplate().update(sql, money, out);  
  30. }  
  31.   
  32.   
  33. /** 
  34. * @param in :转入账号 
  35. * @param money:转账金额 
  36. */  
  37. @Override  
  38. public void inMoney(String in, Double money) {  
  39. String sql = "update account set money = money+? where name = ?";  
  40. this.getJdbcTemplate().update(sql,money,in);  
  41. }  
  42.   
  43.   
  44. }  


5.1.3 Service层

[java] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. public interface AccountService {  
  2.   
  3.   
  4. /** 
  5. * @param out :转出账号 
  6. * @param in :转入账号 
  7. * @param money:转账金额 
  8. */  
  9. public void transfer(String out,String in,Double money);  
  10. }  
  11.   
  12.   
  13. public class AccountServiceImpl implements AccountService {  
  14.   
  15. //注入转账的DAO  
  16. private AccountDao accountDao;  
  17.   
  18.   
  19. //注入事务管理的模板  
  20. private TransactionTemplate transactionTemplate;  
  21.   
  22.   
  23. /** 
  24. * @param out :转出账号 
  25. * @param in :转入账号 
  26. * @param money:转账金额 
  27. */  
  28. @Override  
  29. public void transfer(final String out, final String in, final Double money) {  
  30. /*accountDao.outMoney(out, money); 
  31. //int i = 1/0; 
  32. accountDao.inMoney(in, money);*/  
  33.   
  34. //  
  35. transactionTemplate.execute(new TransactionCallbackWithoutResult() {  
  36.   
  37.   
  38. @Override  
  39. protected void doInTransactionWithoutResult(TransactionStatus transactionStatus) {  
  40. accountDao.outMoney(out, money);  
  41. //int i = 1/0;  
  42. accountDao.inMoney(in, money);  
  43. }  
  44. });  
  45. }  
  46.   
  47.   
  48. public void setAccountDao(AccountDao accountDao) {  
  49. this.accountDao = accountDao;  
  50. }  
  51.   
  52.   
  53. public void setTransactionTemplate(TransactionTemplate transactionTemplate) {  
  54. this.transactionTemplate = transactionTemplate;  
  55. }  
  56.   
  57.   
  58. }  


5.1.4 xml配置

[java] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.      xmlns:context="http://www.springframework.org/schema/context"  
  5.      xmlns:aop="http://www.springframework.org/schema/aop"  
  6.      xmlns:tx="http://www.springframework.org/schema/tx"  
  7.      xmlns:task="http://www.springframework.org/schema/task"  
  8.      xsi:schemaLocation="http://www.springframework.org/schema/beans  
  9.          http://www.springframework.org/schema/beans/spring-beans-3.1.xsd  
  10.          http://www.springframework.org/schema/context  
  11.          http://www.springframework.org/schema/context/spring-context-3.1.xsd  
  12.          http://www.springframework.org/schema/aop  
  13.          http://www.springframework.org/schema/aop/spring-aop-3.1.xsd  
  14.          http://www.springframework.org/schema/tx  
  15.          http://www.springframework.org/schema/tx/spring-tx-3.1.xsd  
  16.          http://www.springframework.org/schema/task  
  17. http://www.springframework.org/schema/task/spring-task-3.1.xsd">  
  18.   
  19.   
  20. <!-- 引入外部的属性文件 -->  
  21. <context:property-placeholder location="classpath:jdbc.properties"/>  
  22.   
  23. <!-- 配置c3p0连接池 -->  
  24. <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">  
  25. <property name="driverClass" value="${jdbc.driverClass}" />  
  26. <property name="jdbcUrl" value="${jdbc.url}" />  
  27. <property name="user" value="${jdbc.username}" />  
  28. <property name="password" value="${jdbc.password}" />  
  29. </bean>  
  30.   
  31. <!-- 配置业务层类 -->  
  32. <bean id="accountService" class="com.zs.spring.demo1.AccountServiceImpl">  
  33. <property name="accountDao" ref="accountDao" />  
  34. <!-- 注入事务管理的模板 -->  
  35. <property name="transactionTemplate" ref="transactionTemplate" />  
  36. </bean>  
  37.   
  38. <!-- 配置DAO类(简化,会自动配置JdbcTemplate) -->  
  39. <bean id="accountDao" class="com.zs.spring.demo1.AccountDaoImpl">  
  40. <property name="dataSource" ref="dataSource" />  
  41. </bean>  
  42.   
  43. <!-- 配置DAO类(未简化) -->  
  44. <!-- <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">  
  45. <property name="dataSource" ref="dataSource" />  
  46. </bean>  
  47. <bean id="accountDao" class="com.zs.spring.demo1.AccountDaoImpl">  
  48. <property name="jdbcTemplate" ref="jdbcTemplate" />  
  49. </bean> -->  
  50.   
  51. <!-- ==================================1.编程式的事务管理=============================================== -->  
  52. <!-- 配置事务管理器 -->  
  53. <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">  
  54. <property name="dataSource" ref="dataSource" />  
  55. </bean>  
  56.   
  57. <!-- 配置事务管理的模板:Spring为了简化事务管理的代码而提供的类 -->  
  58. <bean id="transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate">  
  59. <property name="transactionManager" ref="transactionManager"/>  
  60. </bean>  
  61.   
  62. </beans>  


5.1.5 测试

[java] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. @RunWith(SpringJUnit4ClassRunner.class)  
  2. @ContextConfiguration("classpath:applicationContext1.xml")  
  3. public class TransactionTest {  
  4.   
  5.   
  6. @Resource(name="accountService")  
  7. private AccountService accountService;  
  8.   
  9. @Test  
  10. public void demo1(){  
  11. accountService.transfer("aaa""bbb", 200d);  
  12. }  
  13. }  



5.2 使用xml配置申明式事务管理

代码侵入性小,是通过spring aop 实现的。

   5.2.1 使用XML配置声明式的事务管理(原始方式)

Service层的变化

[java] view plain copy
 在CODE上查看代码片派生到我的代码片
  1.  public class AccountServiceImpl implements AccountService {  
  2.   
  3. //注入转账的DAO  
  4. private AccountDao accountDao;  
  5. public void setAccountDao(AccountDao accountDao) {  
  6. this.accountDao = accountDao;  
  7. }  
  8.   
  9.   
  10. /** 
  11. * @param out :转出账号 
  12. * @param in :转入账号 
  13. * @param money:转账金额 
  14. */  
  15. @Override  
  16. public void transfer( String out, String in, Double money) {  
  17. accountDao.outMoney(out, money);  
  18. //int i = 1/0;  
  19. accountDao.inMoney(in, money);  
  20.   
  21. }  
  22.   
  23. }  

xml的变化

[java] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.      xmlns:context="http://www.springframework.org/schema/context"  
  5.      xmlns:aop="http://www.springframework.org/schema/aop"  
  6.      xmlns:tx="http://www.springframework.org/schema/tx"  
  7.      xmlns:task="http://www.springframework.org/schema/task"  
  8.      xsi:schemaLocation="http://www.springframework.org/schema/beans  
  9.          http://www.springframework.org/schema/beans/spring-beans-3.1.xsd  
  10.          http://www.springframework.org/schema/context  
  11.          http://www.springframework.org/schema/context/spring-context-3.1.xsd  
  12.          http://www.springframework.org/schema/aop  
  13.          http://www.springframework.org/schema/aop/spring-aop-3.1.xsd  
  14.          http://www.springframework.org/schema/tx  
  15.          http://www.springframework.org/schema/tx/spring-tx-3.1.xsd  
  16.          http://www.springframework.org/schema/task  
  17. http://www.springframework.org/schema/task/spring-task-3.1.xsd">  
  18.   
  19.   
  20. <!-- 引入外部的属性文件 -->  
  21. <context:property-placeholder location="classpath:jdbc.properties"/>  
  22.   
  23. <!-- 配置c3p0连接池 -->  
  24. <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">  
  25. <property name="driverClass" value="${jdbc.driverClass}" />  
  26. <property name="jdbcUrl" value="${jdbc.url}" />  
  27. <property name="user" value="${jdbc.username}" />  
  28. <property name="password" value="${jdbc.password}" />  
  29. </bean>  
  30.   
  31. <!-- 配置业务层类 -->  
  32. <bean id="accountService" class="com.zs.spring.demo2.AccountServiceImpl">  
  33. <property name="accountDao" ref="accountDao" />  
  34. </bean>  
  35.   
  36. <!-- 配置DAO类(简化,会自动配置JdbcTemplate) -->  
  37. <bean id="accountDao" class="com.zs.spring.demo2.AccountDaoImpl">  
  38. <property name="dataSource" ref="dataSource" />  
  39. </bean>  
  40.   
  41. <!-- ==================================2.使用XML配置声明式的事务管理(原始方式)=============================================== -->  
  42.   
  43. <!-- 配置事务管理器 -->  
  44. <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">  
  45. <property name="dataSource" ref="dataSource" />  
  46. </bean>  
  47.   
  48. <!-- 配置业务层的代理 -->  
  49. <bean id="accountServiceProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">  
  50. <!-- 配置目标对象 -->  
  51. <property name="target" ref="accountService" />  
  52. <!-- 注入事务管理器 -->  
  53. <property name="transactionManager" ref="transactionManager"></property>  
  54. <!-- 注入事务的属性 -->  
  55. <property name="transactionAttributes">  
  56. <props>  
  57. <!--   
  58. prop的格式:  
  59. * PROPAGATION :事务的传播行为  
  60. * ISOTATION :事务的隔离级别  
  61. * readOnly :只读  
  62. * -EXCEPTION :发生哪些异常回滚事务  
  63. * +EXCEPTION :发生哪些异常不回滚事务  
  64. -->  
  65. <prop key="transfer">PROPAGATION_REQUIRED</prop>  
  66. <!-- <prop key="transfer">PROPAGATION_REQUIRED,readOnly</prop> -->  
  67. <!-- <prop key="transfer">PROPAGATION_REQUIRED,+java.lang.ArithmeticException</prop> -->  
  68. </props>  
  69. </property>  
  70. </bean>  
  71.   
  72.   
  73. </beans>  


 test类的变化

[java] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. @RunWith(SpringJUnit4ClassRunner.class)  
  2. @ContextConfiguration("classpath:applicationContext2.xml")  
  3. public class TransactionTest {  
  4.   
  5.   
  6. /** 
  7. * 一定要注入代理类:因为代理类进行增强的操作 
  8. */  
  9. //@Resource(name="accountService")  
  10. @Resource(name="accountServiceProxy")  
  11. private AccountService accountService;  
  12.   
  13. @Test  
  14. public void demo1(){  
  15. accountService.transfer("aaa""bbb", 200d);  
  16. }  
  17. }  



5.3 使用XML配置声明式的事务管理,基于tx/aop

  5.3.1 xml配置

[java] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.      xmlns:context="http://www.springframework.org/schema/context"  
  5.      xmlns:aop="http://www.springframework.org/schema/aop"  
  6.      xmlns:tx="http://www.springframework.org/schema/tx"  
  7.      xmlns:task="http://www.springframework.org/schema/task"  
  8.      xsi:schemaLocation="http://www.springframework.org/schema/beans  
  9.          http://www.springframework.org/schema/beans/spring-beans-3.1.xsd  
  10.          http://www.springframework.org/schema/context  
  11.          http://www.springframework.org/schema/context/spring-context-3.1.xsd  
  12.          http://www.springframework.org/schema/aop  
  13.          http://www.springframework.org/schema/aop/spring-aop-3.1.xsd  
  14.          http://www.springframework.org/schema/tx  
  15.          http://www.springframework.org/schema/tx/spring-tx-3.1.xsd  
  16.          http://www.springframework.org/schema/task  
  17. http://www.springframework.org/schema/task/spring-task-3.1.xsd">  
  18.   
  19.   
  20. <!-- 引入外部的属性文件 -->  
  21. <context:property-placeholder location="classpath:jdbc.properties"/>  
  22.   
  23. <!-- 配置c3p0连接池 -->  
  24. <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">  
  25. <property name="driverClass" value="${jdbc.driverClass}" />  
  26. <property name="jdbcUrl" value="${jdbc.url}" />  
  27. <property name="user" value="${jdbc.username}" />  
  28. <property name="password" value="${jdbc.password}" />  
  29. </bean>  
  30.   
  31. <!-- 配置业务层类 -->  
  32. <bean id="accountService" class="com.zs.spring.demo3.AccountServiceImpl">  
  33. <property name="accountDao" ref="accountDao" />  
  34. </bean>  
  35.   
  36. <!-- 配置DAO类(简化,会自动配置JdbcTemplate) -->  
  37. <bean id="accountDao" class="com.zs.spring.demo3.AccountDaoImpl">  
  38. <property name="dataSource" ref="dataSource" />  
  39. </bean>  
  40.   
  41. <!-- ==================================3.使用XML配置声明式的事务管理,基于tx/aop=============================================== -->  
  42.   
  43. <!-- 配置事务管理器 -->  
  44. <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">  
  45. <property name="dataSource" ref="dataSource" />  
  46. </bean>  
  47.   
  48. <!-- 配置事务的通知 -->  
  49. <tx:advice id="txAdvice" transaction-manager="transactionManager">  
  50. <tx:attributes>  
  51. <!--   
  52. propagation :事务传播行为  
  53. isolation :事务的隔离级别  
  54. read-only :只读  
  55. rollback-for:发生哪些异常回滚  
  56. no-rollback-for:发生哪些异常不回滚  
  57. timeout :过期信息  
  58. -->  
  59. <tx:method name="transfer" propagation="REQUIRED"/>  
  60. </tx:attributes>  
  61. </tx:advice>  
  62.   
  63. <!-- 配置切面 -->  
  64. <aop:config>  
  65. <!-- 配置切入点 -->  
  66. <aop:pointcut expression="execution(* com.zs.spring.demo3.AccountService+.*(..))" id="pointcut1"/>  
  67. <!-- 配置切面 -->  
  68. <aop:advisor advice-ref="txAdvice" pointcut-ref="pointcut1"/>  
  69. </aop:config>  
  70.   
  71.   
  72. </beans>  


5.3.2 test的变化

[java] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. @RunWith(SpringJUnit4ClassRunner.class)  
  2. @ContextConfiguration("classpath:applicationContext3.xml")  
  3. public class TransactionTest {  
  4.   
  5.   
  6.   
  7. @Resource(name="accountService")  
  8. private AccountService accountService;  
  9.   
  10. @Test  
  11. public void demo1(){  
  12. accountService.transfer("aaa""bbb", 200d);  
  13. }  
  14. }  


5.4 事务注解的实现

    5.4.1 xml配置

[java] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  4.      xmlns:context="http://www.springframework.org/schema/context"  
  5.      xmlns:aop="http://www.springframework.org/schema/aop"  
  6.      xmlns:tx="http://www.springframework.org/schema/tx"  
  7.      xmlns:task="http://www.springframework.org/schema/task"  
  8.      xsi:schemaLocation="http://www.springframework.org/schema/beans  
  9.          http://www.springframework.org/schema/beans/spring-beans-3.1.xsd  
  10.          http://www.springframework.org/schema/context  
  11.          http://www.springframework.org/schema/context/spring-context-3.1.xsd  
  12.          http://www.springframework.org/schema/aop  
  13.          http://www.springframework.org/schema/aop/spring-aop-3.1.xsd  
  14.          http://www.springframework.org/schema/tx  
  15.          http://www.springframework.org/schema/tx/spring-tx-3.1.xsd  
  16.          http://www.springframework.org/schema/task  
  17. http://www.springframework.org/schema/task/spring-task-3.1.xsd">  
  18.   
  19.   
  20. <!-- 引入外部的属性文件 -->  
  21. <context:property-placeholder location="classpath:jdbc.properties"/>  
  22.   
  23. <!-- 配置c3p0连接池 -->  
  24. <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">  
  25. <property name="driverClass" value="${jdbc.driverClass}" />  
  26. <property name="jdbcUrl" value="${jdbc.url}" />  
  27. <property name="user" value="${jdbc.username}" />  
  28. <property name="password" value="${jdbc.password}" />  
  29. </bean>  
  30.   
  31. <!-- 配置业务层类 -->  
  32. <bean id="accountService" class="com.zs.spring.demo4.AccountServiceImpl">  
  33. <property name="accountDao" ref="accountDao" />  
  34. </bean>  
  35.   
  36. <!-- 配置DAO类(简化,会自动配置JdbcTemplate) -->  
  37. <bean id="accountDao" class="com.zs.spring.demo4.AccountDaoImpl">  
  38. <property name="dataSource" ref="dataSource" />  
  39. </bean>  
  40.   
  41. <!-- ==================================4.使用注解配置声明式事务============================================ -->  
  42.   
  43.   
  44. <!-- 配置事务管理器 -->  
  45. <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">  
  46. <property name="dataSource" ref="dataSource" />  
  47. </bean>  
  48.   
  49. <!-- 开启注解事务 -->  
  50. <tx:annotation-driven transaction-manager="transactionManager"/>  
  51.   
  52. </beans>  


5.4.2 Serverce

[java] view plain copy
 在CODE上查看代码片派生到我的代码片
  1.  *@Transactional(Propagation.REQUIRED)中的的属性  
  2.  *propagation :事务的传播行为  
  3.  *isolation :事务的隔离级别  
  4.  *readOnly :只读  
  5.  *rollbackFor :发生哪些异常回滚  
  6.  *noRollbackFor :发生哪些异常不回滚  
  7.  *rollbackForClassName 根据异常类名回滚  
  8.  */  
  9. @Transactional  
  10. public class AccountServiceImpl implements AccountService {  
  11.   
  12. //注入转账的DAO  
  13. private AccountDao accountDao;  
  14.   
  15.   
  16.   
  17. /** 
  18. * @param out :转出账号 
  19. * @param in :转入账号 
  20. * @param money:转账金额 
  21. */  
  22. @Override  
  23. public void transfer( String out, String in, Double money) {  
  24. accountDao.outMoney(out, money);  
  25. //int i = 1/0;  
  26. accountDao.inMoney(in, money);  
  27.   
  28. }  
  29.   
  30.   
  31. public void setAccountDao(AccountDao accountDao) {  
  32. this.accountDao = accountDao;  
  33. }  
  34.   
  35.   
  36. }  


[java] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. <pre code_snippet_id="2296147" snippet_file_name="singit" name="code" class="java"><pre code_snippet_id="2296147" snippet_file_name="singit"></pre>  
  2. <pre></pre>  
  3. <pre></pre>  
  4. <pre></pre>  
  5. <pre></pre>  
  6. <pre></pre>  
  7. <pre></pre>  
  8. <pre></pre>  
  9. <pre></pre>  
  10. <pre></pre>  
  11. <pre></pre>  
  12.      
  13. </pre>  

[java] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. <pre code_snippet_id="2296147" snippet_file_name="singit" name="code" class="java"><pre code_snippet_id="2296147" snippet_file_name="singit"></pre>  
  2. <pre></pre>  
  3. <pre></pre>  
  4. <pre></pre>  
  5. <pre></pre>  
  6. <pre></pre>  
  7. <pre></pre>  
  8. <pre></pre>  
  9. <pre></pre>  
  10. <pre></pre>  
  11. <pre></pre>  
  12.      
  13. </pre>  

[java] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. <pre code_snippet_id="2296147" snippet_file_name="singit" name="code" class="java"><pre code_snippet_id="2296147" snippet_file_name="singit"></pre>  
  2. <pre></pre>  
  3. <pre></pre>  
  4. <pre></pre>  
  5. <pre></pre>  
  6. <pre></pre>  
  7. <pre></pre>  
  8. <pre></pre>  
  9. <pre></pre>  
  10. <pre></pre>  
  11. <pre></pre>  
  12.      
  13. </pre>  

声明:本篇文章经http://www.imooc.com/learn/478整理而出。如有侵权请联系博主,谢谢。
[java] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. <pre code_snippet_id="2296147" snippet_file_name="singit" name="code" class="java"><pre code_snippet_id="2296147" snippet_file_name="singit"></pre>  
  2. <pre></pre>  
  3. <pre></pre>  
  4. <pre></pre>  
  5. <pre></pre>  
  6. <pre></pre>  
  7. <pre></pre>  
  8. <pre></pre>  
  9. <pre></pre>  
  10. <pre></pre>  
  11. <pre></pre>  
  12.      
  13. </pre>  
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值