mybatis +junit4 +maven
来源:互联网 发布:超级电子仿真软件 编辑:程序博客网 时间:2024/06/06 01:20
1、junit4 测试插入数据时回滚
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:spring-mvc.xml", "classpath:spring-ctx-mybatis.xml", "classpath:spring-ctx-shiro.xml" })
public class SysVersionMapperTest {
@Autowired
private SysVersionMapper sysVersionMapper;
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
@Test
@Transactional
@Rollback(true)
public void testInsert() {
Map<String, Object> rd = new HashMap<>();
rd.put("sys_name", "Emt后台管理系统-工单处理");
rd.put("version", "3.0.0.1bete");
rd.put("describe", "更新内容:\n 1.实时查询订单 在专卖店系统内可以实时查询订单状态为关闭或待付款的订单,协助经销商发现潜在的客户");
rd.put("svn", "620");
rd.put("update_oper_code", "admin");
System.out.println("插入系统版本:" + sysVersionMapper.Insert(rd));
}
}
加入红色部分字体;加入后依然回滚不了报错: Manual close is not allowed over a Spring managed SqlSession;在sysSqlSession配置中加入scope
<bean id="sysSqlSession" class="org.mybatis.spring.SqlSessionTemplate"scope="prototype">
<constructor-arg index="0" ref="sysSqlSessionFactory" />
</bean>
亲测,ok
- mybatis +junit4 +maven
- maven Junit4.1 BUG
- SSM框架+Redis整合遇到的问题汇总(Spring+SpringMVC+Mybatis+PostgreSQL+Tomcat7+Redis+Maven+JUnit4.12)v.14
- maven mybatis
- MAVEN项目添加junit4测试用例
- eclipse创建springmvc+maven+junit4 web 项目
- intellij idea maven 工程junit4单元测试
- Junit4 with Intellij Idea and Maven
- JUnit4
- JUnit4
- junit4
- junit4
- JUnit4
- junit4
- JUnit4
- JUNIT4
- Junit4
- JUnit4
- python爬虫(二)爬取知乎问答
- 安卓5.1源码解析 : RecyclerView解析 从绘制流程,ViewHolder复用机制,LayoutManger,ItemAnimator等流程全面讲解
- 用css画三角形
- Android基础_网络请求/AsyTaskDemo(六)
- 重入锁 (替换synchronized)
- mybatis +junit4 +maven
- js千位符
- ssm文件上传
- 杭电acm2012 素数判定
- 二叉树的定义及实现
- 根据checkBox的状态,控制按钮可否点击。不可点击置灰
- 学不可以已_001
- Spring JdbcTemplate query查询结果转换对象
- RH134-第二十二节-高级网络配置