`
shiwj1010
  • 浏览: 97314 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

spring+struts在service层的事务控制,applicationContext.xml

    博客分类:
  • j2ee
阅读更多
使用spring中的jdbcTemplate,一种配置。在一个service层中,有些情况是会同时调用不同的dao,对数据库进行存取操作,而这些操作具有原子性,即其中任何一个dao操作发生异常,整个受事务管理的方法都要rollback.
<?xml version="1.0" encoding="UTF-8"?>
<beans
	xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">

	<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
		<property name="driverClassName"
			value="org.hsqldb.jdbcDriver">
		</property>
		<property name="url"
			value="jdbc:hsqldb:hsql://localhost/xdb">
		</property>
		<property name="username" value="sa"></property>
		<property name="password" value="hsql"></property>
	</bean>

	<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">   
        <property name="dataSource" ref="dataSource"/>   
     </bean>
     
     <bean id="baseTxProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" lazy-init="true">   
        <property name="transactionManager">   
        	<ref bean="transactionManager" />   
         </property>   
         <property name="transactionAttributes">   
         <props>   
             <prop key="*">PROPAGATION_REQUIRED</prop>   
        </props>   
         </property>   
    </bean>
    
	<bean id="studentManagerService" parent="baseTxProxy" >   
		<property name="target">   
			<bean class="chuck.service.impl.StudentManagerServiceImpl">        
				<property name="studentDao">   
					<ref bean="studentDAO"/>   
				</property>        
			</bean>     
		</property>     
	</bean> 
     
     <bean id="studentDAO" class="chuck.dao.impl.StudentDAOImpl">   
       <property name="dataSource" ref="dataSource"/>   
    </bean>   
     
</beans>
分享到:
评论

相关推荐

    struts2+spring+hibernate整合示例

    a 加入支持 : 添加struts2.3.15 必需包 以及 struts json包(ajax要用到),spring整合struts2包,spring web 包,在src目录下建立struts.xml,复制头文件进去。将applicationContext.xml移到WEB-INF目录下。web容器...

    Ext+struts2+spring+hibernate做的一个CRUD实例

    用EXT+struts2+spring+hibernate做...另外因包太多无法上传,所以请大家自己在myeclipse里面加上spring和hibernate,struts2运行的jar包,jar列表请看根目录下面的txt文件。另外,不会使用的不要再后面骂人,很无趣的!

    ssm(spring+Struts2+mybatis)开发CRM客户关系信息管理系统

    spring+Struts2+mybatis+bootstrap+jquery 注意事项 1.applicationContext.xml目录不在常见的目录下F4Crm\src\com\chinasoft\ssm\admin\resource下 2.在配置文件中,li连接数据库的ip地址得改成自己的 还有连接...

    applicationContext.xml

    spring struts hibernate 的配置文件

    spring考试通过必备材料.docx

    在struts.xml中配置页面跳转关系, 21 在applicationContext.xml中配置类之间的调用关系, 22 通知 23 通知文件MyAdvice,schema方法的通知 23 在applicationContext.xml中配置通知--通知文件logAdvice 25 引用AOP的...

    Struts+Spring+Hibernate快速入门

     •装载Spring的applicationContext.xml文件  •建立业务层和DAO之间的依赖关系  •将Spring应用到Struts中  简介  这个例子是建立一个简单的web应用,叫MyUsers,完成用户管理操作,包含简单的数据库增,删,...

    struts+spring+hibernate架构

    &lt;br&gt;使用方法: (1)在oracle数据库中运行数据库脚本文件cnc.sql. (2)用eclipse(或其它开发工具)直接导入工程. (3)将spring配置文件applicationContext.xml中数据库连接地址改为您自已的地址。...

    Spring + Hibernate + Struts 事务配置小例子(带提示框等小技巧)

    今天修改了 applicationContext.xml,以后的事务控制就万事大吉了,里面有详细注释哦。 有什么问题可以给我留言 ^_^,大家一起进步! &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;!DOCTYPE beans PUBLIC "-//SPRING//...

    Struts2.3.16.1+Hibernate3.6.10+Spring3.2.8整合

    Struts2.3.16.1+Hibernate3.6.10+Spring3.2.8整合 能够运行,没有任何问题 另外附带applicationContext.xml、struts.xml、hibernate.cfg.xml

    新闻发布系统 Struts+Hibernate+Spring

    使用了Struts+Hibernate+Spring来构建整个网站。 布局使用了CSS和DIV。 部署前请修改以下文件: NewReleseSystem\WebRoot\WEB-INF下面的applicationContext.xml文件 修改里面的数据库的用户名和密码为你所安装的...

    Spring 3.0+Struts2+Mybatis 3 + p6spy 平台框架

    这是自己整合的Spring 3.0+Struts2+Mybatis 3 + p6spy +ehcache的平台框架,内含一点示例代码,目前ehcache没有使用。直接编译后发布就能用 测试环境基于JDK1.6+Tomcat 6.0. 大家拿到后请根据实际情况修改 ...

    Spring+Spring MVC+Struts+hibernate开发摄影平台完整版系统

    今天在这里分享一个当初给学弟学妹做的毕业设计,系统功能完整,改改完全能用于毕业设计,数据库齐全,初始链接密码为root,配置数据库在applicationContext.xml里

    Spring+Spring MVC+Struts+hibernate开发的摄影平台完整版系统

    含文档,系统功能完整,数据库齐全,初始链接密码为root,配置数据库在applicationContext.xml里 后台管理员,可以自己添加设置,初始为:admin,admin localhost:8080/sypt

    JAVA SSH青协志愿服务管理系统源码.rar

    4,service 逻辑业务层 5,util 工具类 log4j.properties 日志文件 *.properties配置文件 Struts.xml 配置action WebRoot根目录 fckeditor在线编辑器, images img 图片 upload,updown 上传下载, admin common ...

    使用Struts+Spring+Hibernate整合开发例子

    注意:在添加hibernate框架时,选择生成spring configuration file (applicationContext.xml)。 这里是使用spring配置文件管理hibernate。 先配置mysql数据驱动,打开eclipse database explorer perspective,选择...

    JAVA SSH青协志愿服务管理系统源码

    4,service 逻辑业务层 5,util 工具类 log4j.properties 日志文件 *.properties配置文件 Struts.xml 配置action WebRoot根目录 fckeditor在线编辑器, images img 图片 upload,updown 上传下载, admin common ...

    spring+hibernate+struts2开发OA企业办公管理系统源码

    工程里面直接有数据库和lib包,最好去网盘在重新下载一份,我把之前的工程的数据库删掉了 数据库新建:test 字符:UTF-8,本地如果有test数据库,最好删掉,以免表关联导致数据不对 数据库帐号和密码都没有加密,...

    ssh:struts-2.5+spring4+hibernate5

    简单的ssh项目,泛型BaseAction配置,简单注解配置,applicationContext.xml配置,jar包地址 链接:https://pan.baidu.com/s/14NkywuhG6mESyhE1VMkhOQ 密码:en19

    SSH概要介绍

    6、将applicationContext.xml的事务传播控制器,注解注入service接口实现类,在需要事务的地方,注解配置事务控制。将Dao接口注解注入service接口实现类,接口实现类调用Dao接口,将action所要的操作,传递给Dao接口...

Global site tag (gtag.js) - Google Analytics