spring springmvc 将事物管理(@Transactional)分别加在 controller和service层
来源:互联网 发布:艾泽拉斯数据库 人口 编辑:程序博客网 时间:2024/05/22 14:15
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
- 解决c语言中调用scanf()或者strcpy()函数报错问题
- SQL注入基础
- 转:微信序列号生成器架构设计及演变(下)
- 防止表单重复提交订单
- C++基于TCP的网络应用程序的编写
- spring springmvc 将事物管理(@Transactional)分别加在 controller和service层
- C/C++中extern关键字详解与应用
- 位运算
- 关于事务的一些基本概念
- LeetCode(455)Assign Cookies
- 多态中的this参数
- 通过SSH实现 端口映射
- 设置隐藏标题栏
- Ubuntu中的符号