步骤:

1.添加aop、tx命名空间声明;

2.配置事务管理器;

3.配置增强;

4.配置aop

具体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:p="http://www.springframework.org/schema/p"
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-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
"> <bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver">
</property>
<property name="url"
value="jdbc:oracle:thin:@localhost:1521:orcl">
</property>
<property name="username" value="system"></property>
<property name="password" value="ok"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/it/entity/Stu.hbm.xml</value></list>
</property>
</bean>
<!-- spring声明式事务 3个步骤-->
<!-- 1 事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- 2 增强 -->
<tx:advice id="tx" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="batch*"/>
</tx:attributes>
</tx:advice>
<!-- 3 aop -->
<aop:config>
<aop:pointcut expression="execution(* com.it.biz.impl.*.*(..))" id="pt"/>
<aop:advisor advice-ref="tx" pointcut-ref="pt"/>
</aop:config>
<!-- spring声明式事务写在最上面 --> <!-- stuDao -->
<bean id="studao" class="com.it.dao.impl.StuDaoImpl">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- stuBiz -->
<bean id="stubiz" class="com.it.biz.impl.StuBizImpl">
<property name="studao" ref="studao"/>
</bean>
<!-- stuAction -->
<bean id="stuaction" class="com.it.action.StuAction">
<property name="stubiz" ref="stubiz"/>
</bean> </beans>

最新文章

  1. jmeter(十)参数化
  2. 为GitHub项目加入Travis-CI的自动集成
  3. 4.1---二叉树是否平衡(CC150)
  4. LoadRunner性能测试执行过程的问题
  5. 关于DIV+CSS和XHTML+CSS的理解
  6. BAE3.0搭建wordpress注意
  7. javascript的getter和setter(转)
  8. Asp.net mvc 中Action 方法的执行(一)
  9. 爬取博主所有文章并保存到本地(.txt版)--python3.6
  10. Python 双向链表
  11. python--再看并行之协程线程进程
  12. mysql 安装问题三:FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db: Data::Dumper
  13. PHP魔术方法实例
  14. RPi 3B 无线连接配置
  15. PHP判断是否都是中文
  16. pytorch总结
  17. repeat 中的 continue
  18. Cocos2dx 3.0 过渡篇(二十七)C++11多线程std::thread的简单使用(下)
  19. POJ 1860 Currency Exchange(Bellman-Ford)
  20. 使用ESP8266连接到Azure

热门文章

  1. Go mod graphql-go 的 Replace
  2. js中将json字符串转换成json对象
  3. js中要声明变量吗?
  4. 计蒜客 王子救公主(DFS)
  5. c# 异常处理 try --catch
  6. 一文详解 Java 的八大基本类型
  7. Celery架构
  8. 远程SSH服务使用指南
  9. Filezilla Xshell SecureFX Win10等无法拖放文件(本地或线上)解决办法
  10. iOS 加急审核的办法