`

spring+ibatis+struts事务控制配置

阅读更多
<?xml version="1.0" encoding="UTF-8"?>

<!--
  - Application context definition for JPetStore's business layer.
  - Contains bean references to the transaction manager and to the DAOs in
  - dataAccessContext-local/jta.xml (see web.xml's "contextConfigLocation").
  -->
<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-2.0.xsd
          http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">


<!-- ========================= GENERAL DEFINITIONS ========================= -->

<!-- Configurer that replaces ${...} placeholders with values from properties files -->
<!-- (in this case, mail and JDBC related properties) -->
<!-- serviceBean -->
<bean id="changingService" class="cn.edu.ysu.spring.service.ChangingService">
  <property name="changingDao" ref="changingDAOImpl"> </property>
    <property name="contractDao" ref="contractDAOImpl"> </property>
    <property name="reportDao" ref="reportDAOImpl"> </property>
    <property name="projectDao" ref="projectDAOImpl"> </property>
    <property name="scientistDao" ref="scientistDAOImpl"> </property>
</bean>
<bean id="contractService" class="cn.edu.ysu.spring.service.ContractService">
      <property name="changingDao" ref="changingDAOImpl"> </property>
    <property name="contractDao" ref="contractDAOImpl"> </property>
    <property name="reportDao" ref="reportDAOImpl"> </property>
    <property name="projectDao" ref="projectDAOImpl"> </property>
    <property name="scientistDao" ref="scientistDAOImpl"> </property>
</bean>
<bean id="projectService" class="cn.edu.ysu.spring.service.ProjectService">
    <property name="changingDao" ref="changingDAOImpl"> </property>
    <property name="contractDao" ref="contractDAOImpl"> </property>
    <property name="reportDao" ref="reportDAOImpl"> </property>
    <property name="projectDao" ref="projectDAOImpl"> </property>
    <property name="scientistDao" ref="scientistDAOImpl"> </property>
</bean>
<bean id="reportService" class="cn.edu.ysu.spring.service.ReportService">
    <property name="changingDao" ref="changingDAOImpl"> </property>
    <property name="contractDao" ref="contractDAOImpl"> </property>
    <property name="reportDao" ref="reportDAOImpl"> </property>
    <property name="projectDao" ref="projectDAOImpl"> </property>
    <property name="scientistDao" ref="scientistDAOImpl"> </property>
</bean>
<bean id="scientistService" class="cn.edu.ysu.spring.service.ScientistService">
    <property name="changingDao" ref="changingDAOImpl"> </property>
    <property name="contractDao" ref="contractDAOImpl"> </property>
    <property name="reportDao" ref="reportDAOImpl"> </property>
    <property name="projectDao" ref="projectDAOImpl"> </property>
    <property name="scientistDao" ref="scientistDAOImpl"> </property>
  </bean>

<!-- 配置数据源 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
  <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/kyproject"/>
<property name="username" value="root"/>
<property name="password" value="1234"/>
</bean>

<!-- 管理ibatis的事务,加载sql-map-config.xml文件 -->
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation" >
  <value>
  classpath:cn\edu\ysu\dao\sqlmap\sql-map-config.xml
  </value>
</property>
<property name="dataSource" ref="dataSource"/>
</bean>

<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  <property name="dataSource" ref="dataSource"> </property>
</bean>

<!-- daoBean -->
  <bean id="changingDAOImpl" class="cn.edu.ysu.dao.daoImplement.ChangingDAOImpl">
        <property name="sqlMapClient" ref="sqlMapClient"/>
</bean>
<bean id="contractDAOImpl" class="cn.edu.ysu.dao.daoImplement.ContractDAOImpl">
  <property name="sqlMapClient" ref="sqlMapClient"/>
</bean>
<bean id="projectDAOImpl" class="cn.edu.ysu.dao.daoImplement.ProjectDAOImpl">
  <property name="sqlMapClient" ref="sqlMapClient"/>
</bean>
<bean id="reportDAOImpl" class="cn.edu.ysu.dao.daoImplement.ReportDAOImpl">
    <property name="sqlMapClient" ref="sqlMapClient"/>
</bean>

<bean id="scientistDAOImpl" class="cn.edu.ysu.dao.daoImplement.ScientistDAOImpl">
  <property name="sqlMapClient" ref="sqlMapClient"/>
</bean>


<!-- 代理,事务管理器,定义事务 -->
<bean id="daoProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
  <property name="transactionManager" ref="transactionManager"> </property>
  <property name="target">
  <list>
    <ref local="scientistService"/>
    <ref local="changingService"/>
    <ref local="contractService"/>
    <ref local="projectService"/>
    <ref local="reportService"/>
  </list>
  </property>
  <property name="transactionAttributes" >
    <props>
      <prop key="create*">PROPAGATION_REQUIRED </prop>
      <prop key="update*">PROPAGATION_REQUIRED </prop>
      <prop key="remove*">PROPAGATION_REQUIRED </prop>
      <prop key="to*">PROPAGATION_REQUIRED </prop>
      <prop key="*">PROPAGATION_REQUIRED,readOnly </prop>
    </props>
  </property>
</bean>

<!-- 配置事务特性 -->
<!-- 
<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="insert*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
-->
<!-- 配置哪些类的方法需要事务 -->
<!--
<aop:config>
<aop:pointcut id="allMethod" expression="execution(* cn.edu.ysu.spring.service.ServiceManagerImpl.getScientistService(..))"/>
<aop:aspect id="other" ref="">
  <aop:before pointcut-ref="allMethod" method="other"/>
</aop:aspect>
</aop:config>

-->
分享到:
评论

相关推荐

    struts2+spring+ibatis学生管理demo

    struts2整合spring、ibatis学生信息管理系统。事务管理、分页处理

    Spring+Struts+ibatis下配置数据读写分离及事务(一)

    NULL 博文链接:https://wilr.iteye.com/blog/1190524

    Struts2+Ibatis+Spring3.0完整项目(直接运行)

    耗时3天,对Struts2+Ibatis+Spring3.0+JreeChart进行了完整整合 包括Spring3.0的事务配置 OSCache二级缓存的配置 log4j实现输出Sql到控制台 JfreeChart与Struts2,Spring3.0的整合 对一个简单的表实现查询,批量删除...

    Struts2.0+Springframework2.5+ibatis2.3完美整合用户登录及增删改查

    最流行技术Struts2.1 +Spring 2.5.1+ibatis2.3整合开发而成,这与我以前发布的版本中最大特色是整合了Spring2.5.1中的注解功能和半自动化工具ibatis技术,这是本示例的两大特色,简化了配置文件的烦锁,希望能给更多喜欢...

    ibatis 完美例子 一对多 批处理 事务 和 spring struts2集成

    ibatis 完美例子 一对多 批处理 事务 和 spring struts2集成 ,一朵多 插入1万条数据,不到2秒,备注不包含类库

    struts2、spring、ibatis整合

    为了开发方便,打算换一个架构,自己整合了s2sibatis框架,采用spring事务管理数据库,喜欢的可以看看,有什么问题请多多指教!

    spring+struts+hibernate+dwr+jstl做的实例

    struts hibernate dwr 与Spring完全结合,实现用户列表、信息增、删、改、查、维护时用户重名提示等功能,还包括页面自动转码设置(web.xml),Hibernate管理服务按Bean名称拦截并进行Spring事务管理,完全由Spring...

    Struts2 + Spring3 + Mybatis3例子

    Struts2 + Spring3 + Mybatis3集成的例子,例子为添加用户和显示所有用户的例子.事务由spring来管理.工程用Maven3来管理 例子中没有jar包,需要自己用maven下载.

    跟我学spring3(8-13)

    【第八章】 对ORM的支持 之 8.3 集成iBATIS ——跟我学spring3 【第八章】 对ORM的支持 之 8.4 集成JPA ——跟我学spring3 【第九章】 Spring的事务 之 9.1 数据库事务概述 ——跟我学spring3 【第九章】 Spring的...

    iBATIS实战

    2.5.3 配置iBATIS(预览) 37 2.5.4 构建应用程序 38 2.5.5 运行应用程序 39 2.6 iBATIS未来的发展方向 40 2.6.1 Apache软件基金会 40 2.6.2 更简单、更小且依赖性更少 40 2.6.3 更多的扩展点和插件 41 2.6.4 支持更多...

    Spring开发指南

    Struts in Spring 数据持久层 事务管理 持久层封装 JDBC Hibernate in Spring ibatis in Spring Aspect Oriented Programming AOP 概念 AOP in Spring Dynamic Proxy 与Spring AOP CGLib 与 Spring ...

    spring4.3.2参考文档(英文)

    BeanFactory 使用控制反转 (IOC) 模式将应用程序的配置和依赖性规范与实际的应用程序代码分开。 Spring 上下文:Spring 上下文是一个配置文件,向 Spring 框架提供上下文信息。Spring 上下文包括企业服务,例如 ...

    Spring in Action(第二版 中文高清版).part2

    16.2 协同使用Spring和WebWork 2/Struts 2 16.3 集成Spring和Tapestry 16.3.1 集成Spring和Tapestry 3 16.3.2 集成Spring和Tapestry 4 16.4 协同使用Spring和JSF 16.4.1 解析JSF管理的属性 16.4.2 解析Spring...

    Spring in Action(第二版 中文高清版).part1

    16.2 协同使用Spring和WebWork 2/Struts 2 16.3 集成Spring和Tapestry 16.3.1 集成Spring和Tapestry 3 16.3.2 集成Spring和Tapestry 4 16.4 协同使用Spring和JSF 16.4.1 解析JSF管理的属性 16.4.2 解析Spring...

    Spring in Action(第2版)中文版

    16.2协同使用spring和webwork2/struts2 16.3集成spring和tapestry 16.3.1集成spring和tapestry3 16.3.2集成spring和tapestry4 16.4协同使用spring和jsf 16.4.1解析jsf管理的属性 16.4.2解析springbean 16.4.3...

    spring in action英文版

     4.6 Spring和iBATIS  4.6.1 配置SQL Map  4.6.2 使用SqlMapClientTemplate  4.7 Spring和OJB  4.8 小结  第5章 事务管理  5.1 理解事务  5.1.1 仅用4个词解释事务  5.1.2 理解Spring对...

    Spring-Reference_zh_CN(Spring中文参考手册)

    2.4.1. 在XML里更为简单的声明性事务配置 2.4.2. JPA 2.4.3. 异步的JMS 2.4.4. JDBC 2.5. Web层 2.5.1. Spring MVC的表单标签库 2.5.2. Spring MVC合理的默认值 2.5.3. Portlet 框架 2.6. 其他特性 2.6.1. 动态语言...

    Spring 2.5 jar 所有开发包及完整文档及项目开发实例

    Spring 2.0的'spring-jdo.jar', 'spring-jpa.jar', 'spring-hibernate3.jar', 'spring-toplink.jar' 和 'spring-ibatis.jar' 被合并到Spring 2.5大粒度的'spring-orm.jar'中。 Spring 2.5的 'spring-test.jar' 取代...

Global site tag (gtag.js) - Google Analytics