spring springmvc 将事物管理(@Transactional)分别加在 controller和service层
来源:互联网 发布:淘宝申请延长收货时间 编辑:程序博客网 时间:2024/06/04 17:46
spring springmvc 将事物管理(@Transactional)分别加在 controller和service层
版权声明:本文为博主原创文章,未经博主允许不得转载。
1.将事物加在contrller层,只需要在springmvc.xml中加上<tx:annotation-driven/>即可,并且contrller类中加上@Transactional即可。
前提是在spring.xml中要有事物管理器的配置即
<!-- 事务配置 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
2.将事物加在service层,需要在springmvc.xml中加上 <context:component-scan base-package="com.bj.wsl">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" />
</context:component-scan>这句话,在spring.xml中加上 <context:component-scan base-package="com.bj.wsl">
</context:component-scan>,并且service类中加上@Transactional即可。
前提是在spring.xml中要有事物管理器的配置即
<!-- 事务配置 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 使用annotation注解方式配置事务 -->
<tx:annotation-driven transaction-manager="transactionManager" />
这是我具体实施时参照的url:
http://blog.csdn.net/will_awoke/article/details/12002705
http://5880861.blog.51cto.com/5870861/1544168/
- spring springmvc 将事物管理(@Transactional)分别加在 controller和service层
- spring springmvc 将事物管理(@Transactional)分别加在 controller和service层
- spring struts 将事物管理(@Transactional)加在service层
- ssm 将事物加到service层
- Spring 事物管理 @Transactional
- transactional放置在service层还是controller层
- Springmvc controller 层 @Transactional 不起作用
- Spring在service层事物和@AfterThrowing添加日志冲突
- JavaMelody监控Spring Service层和Spring Controller层
- 在Spring MVC中,事务可以加在Controller层
- 在Spring MVC中,事务可以加在Controller层
- 在Spring MVC中,事务可以加在Controller层
- 在Spring MVC中,事务可以加在Controller层
- 在Spring MVC中,事务可以加在Controller层
- Spring MVC中,事务是否可以加在Controller层
- spring事物-@Transactional
- SpringMVC的层:DAO、Service、Controller、View
- 第二次报错:在spring+springMVC+hibernate中,controller调用service层方法或者dao层方法,报错java.lang.NullPointerException
- chapter14_3图像的转置与镜像
- 2017阿里云TECH INSIGHT干货分享第六届隆重回归
- 微信小程序----组件之switch
- nginx反向代理概述做负载均衡
- NVIDIA Jetson TK1手动刷机教程(附图)
- spring springmvc 将事物管理(@Transactional)分别加在 controller和service层
- new和malloc的区别
- Kafka集群搭建
- ipc(一)无名管道示例
- Qt之qDebug输出转义符反斜杠的问题
- leetcode 236. Lowest Common Ancestor of a Binary Tree
- 从getSystemService()出发获取系统服务
- 第二十五节:父子、兄弟、相邻节点定位方式详解
- 使用Dom4j解析XML