springmvc + mybatis 事务管理(全注解式)
来源:互联网 发布:什么是电子数据 编辑:程序博客网 时间:2024/05/23 19:46
我的事务是配置在Controller层 测试中没用Service层,在springMVC的配置文档中开启事务
<?xml version="1.0" encoding="UTF-8"?>
<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"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">
<!-- (事务管理)transaction manager dataSource等其他数据库配置信息在spring-context.xml中配置过 根据启动顺序这里能够发现dataSource -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager" />
@Controller
@Transactional
public class Test{
@Transactional //可不添加
public void service(HttpServletRequest request,HttpServletResponse response) throws Exception{
}
}
注意点: 1. @Transactional注解起作用的方法必须是public类型
2.该方法必须抛出异常.
3.mysql数据库类型的选择(InnoDB)
- springmvc + mybatis 事务管理(全注解式)
- SpringMVC、MyBatis声明式事务管理
- SpringMVC、MyBatis声明式事务管理
- SpringMVC、MyBatis声明式事务管理
- SpringMVC、MyBatis声明式事务管理
- SpringMVC、MyBatis 声明式事务管理
- SpringMVC+MyBatis声明式事务管理
- Spring SpringMVC Mybatis 全注解配置
- 全注解配置事务管理
- SpringMVC、MyBatis声明式事务管理+AOP配置
- SpringMVC+mybatis事务管理
- Mybatis + SpringMVC事务管理
- springMVC+mybatis事务管理配置
- SpringMVC+MyBatis 事务管理二
- Mybatis + SpringMVC事务管理
- Spring事务管理(注解式声明事务管理)
- Spring事务管理(注解式声明事务管理)
- pring事务管理(注解式声明事务管理)
- hibernate注解(1-2-3)+Hibernate @OneToOne懒加载实现解决方案
- excel学习--从基础开始2
- xutils的使用
- vs2010遇到 模块计算机类型“X86”与目标计算机类型“x64”冲突
- Color Spaces
- springmvc + mybatis 事务管理(全注解式)
- 第六次实验 输出星号图
- python中的深拷贝和浅拷贝理解
- 画图解释LAR算法的几何意义
- 应对518PHP漏洞危机,AMH4.2无损升级PHP5.6.9傻瓜式教程!更新
- ORACLE中的varchar2()与nvarchar2()的讲解
- Windows下批处理的使用
- 13-Ajax链接与Ajax表单的快速对比Demo
- 入门超简单python入门神图