spring将service添加事务管理,在applicationContext.xml文件中的设置
在applicationContext.xml文件中的设置为:
1 <beans> 2 <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> 3 <property name="dataSource" ref="dataSource" /> 4 <!-- 注解的类太多了,可以采用packagesToScan来配置,直接扫描包--> 5 <property name="packagesToScan"> 6 <list> 7 <value>com.lcsoft.mobile.bean</value> 8 </list> 9 </property> 10 11 <property name="hibernateProperties"> 12 <props> 13 <prop key="hibernate.dialect">${hibernate.dialect}</prop> 14 <prop key="hibernate.show_sql">${hibernate.showsql}</prop> 15 </props> 16 </property> 17 </bean> 18 19 <!-- 定义事务管理器(声明式的事务) --> 20 <bean id="transactionManager" 21 class="org.springframework.orm.hibernate3.HibernateTransactionManager"> 22 <property name="sessionFactory" ref="sessionFactory" /> 23 </bean> 24 <tx:advice id="txAdvice" transaction-manager="transactionManager"> 25 <tx:attributes> 26 <tx:method name="*" propagation="REQUIRED" /> 27 </tx:attributes> 28 </tx:advice> 29 30 <aop:config> 31 <aop:pointcut id="interceptorPointCuts" 32 expression="execution(* com.mysoft.mobile.*.*(..))" /> 33 <aop:advisor advice-ref="txAdvice" 34 pointcut-ref="interceptorPointCuts" /> 35 </aop:config> 36 37 <bean id="SysUserService" 38 class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" 39 abstract="true"> 40 <property name="transactionManager" ref="transactionManager" /> 41 <property name="transactionAttributes"> 42 <props> 43 <prop key="push*"> 44 PROPAGATION_SUPPORTS,readOnly,-DataAccessException,-BaseException 45 </prop> 46 </props> 47 </property> 48 </bean> 49 </beans>
转载于:https://www.cnblogs.com/yeqrblog/p/4699741.html
spring将service添加事务管理,在applicationContext.xml文件中的设置相关推荐
- springmvc开启事务_在Controller中添加事务管理
写这篇文章之前先说明一下: 1. Controller中添加事务管理,是可行的,但是强烈不推荐,因为不符合实际开发场景,还会导致一系列问题 2. 事务请在Service处理,所有的业务逻辑请写在 Se ...
- Spring系列--声明式事务管理
Spring事务管理概述 Spring的事务管理简化了传统的事务管理流程,并且在一定程序上减少了开发者的工作量. 事务管理的核心接口 在Spring的所有JAR包中包含一个名为Spring-tx-5. ...
- idea中src/main/resources目录下的applicationContext.xml文件访问src/main/webap目录下的配置文件
如图所示,想要在src/main/resources目录下的applicationContext.xml文件中访问src/main/webap目录下的db.properties,需要两步: appli ...
- spring配置c3p0连接池、spring的声明式事务管理
一.spring配置c3p0连接池: 1.导入maven依赖: <!-- https://mvnrepository.com/artifact/com.mchange/c3p0 --> & ...
- Spring基于Annotation实现事务管理
在 Spring 中,除了使用基于 XML 的方式可以实现声明式事务管理以外,还可以通过 Annotation 注解的方式实现声明式事务管理. 使用 Annotation 的方式非常简单,只需要在项目 ...
- spring的annotation-driven配置事务管理器详解
来源:http://blog.sina.com.cn/s/blog_8f61307b0100ynfb.html 这篇文章是我从ITeye上复制来的,看了一遍,觉得很深刻,决定把他复制来,对原作者表示感 ...
- spring 的4种事务管理(1种编程式+3种声明式)
见:http://blog.csdn.net/sinat_25926481/article/details/48208619 Spring的4种事务管理(1种编程式事务+三种声明事务) 一.Sprin ...
- Spring的4种事务管理(1种编程式事务+三种声明事务)
2019独角兽企业重金招聘Python工程师标准>>> Spring的4种事务管理(1种编程式事务+三种声明事务) 一.Spring事务的介绍 二.编程式事务xml的配置 注入后直接 ...
- 全面分析 Spring 的编程式事务管理及声明式事务管理(转)
摘要 Spring 的事务管理是 Spring 框架中一个比较重要的知识点,该知识点本身并不复杂,只是由于其比较灵活,导致初学者很难把握.本教程从基础知识开始,详细分析了 Spring 事务管理的使用 ...
最新文章
- 售卖ssr_博人传148集:SSR鸣人卡牌受追捧,“金钱之术”重现,太子被盯上
- 文本挖掘预处理:向量化与Hash Trick
- java图片转成字符串_JAVA将图片(本地或者网络资源)转为Base64字符串,将base64字符串存储为本地图片...
- linux中wine yum安装,分享|在基于RedHat或Debian的系统上安装 Wine 1.7
- linux 系统盘无法ls,系统故障排除
- Windows GVim
- GIPC2018全球知识产权生态大会
- 第7章[7.22] Ext JS类的继承与混合
- mysql子查询sysdate_MySQL T6 数据库操作——查询(三)高级查询
- linux用openssl制作自签名数字证书
- Update 语法全介绍
- Photoshop辅助线和标尺的使用技巧
- 行级标签文本格式化标签
- 【蓝桥杯2022】- 数的拆分
- 如何智慧的提问(个人笔记)
- APP微信支付的后台实现
- [附源码]java毕业设计电影影评网
- 摄像头网络直播方案LiveGBS部署问题
- Day 02- Vue3 技术_分析工程结构
- 从微信小程序到QQ小程序:云开发CloudBase的一云多端实践
热门文章
- return 0可以不加吗_拼多多开店可以不交保证金? 拼多多0元开店是真的吗?
- 森林怎么训练野人_138年前抓的“野人女孩”,最终命运如何?死前心愿让人心酸...
- python中and和or的惰性求值特点_python中的惰性求值
- 可拖动的进度条_TIM iOS版重大更新:支持语音进度条拖动和暂停
- java 场景处理,最适合使用RxJava处理的四种场景
- 北海焊接机器人_东方自动焊接专机价格优惠
- gsea富集分析结果怎么看_简单的GSEA分析
- kibana创建索引_ELK 索引生命周期管理
- pca 矩阵 迹_再谈协方差矩阵之主成分分析PCA
- Spring Boot配置文件规则以及使用方法官方文档查找以及Spring项目的官方文档查找方法...