spring test junit通用代码
2015-07-29 18:04
453 查看
1.新建一个测试的父类
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:applicationContext.xml")
@TransactionConfiguration(defaultRollback = true)
@Transactional
public class SpringBaseUnitTest extends AbstractJUnit4SpringContextTests {
}
如果applicationContext,xml在maven项目的resources里,则是
如果是放在web-inf下,则是
@ContextConfiguration(locations = "classpath:file:src/main/webapp/WEB-INf/applicationContext.xml")
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:applicationContext.xml")
@TransactionConfiguration(defaultRollback = true)
@Transactional
public class SpringBaseUnitTest extends AbstractJUnit4SpringContextTests {
}
如果applicationContext,xml在maven项目的resources里,则是
classpath:applicationContext.xml
如果是放在web-inf下,则是
@ContextConfiguration(locations = "classpath:file:src/main/webapp/WEB-INf/applicationContext.xml")
相关文章推荐
- JAVA面向对象理解
- java读取注册表
- JAVA基础点汇总(二)
- Java编程思想:第2章 一切都是对象
- spring 多线程
- 删除JDK报错:Error: could not open `C:\Program Files\Java\jre6\lib\i386\jvm.cfg'
- Eclipse中在android项目中出现新建一个Activity后,出现整个工程的报错以及包导入以后无法运行等等情况分析。
- 用泛型的extends影响struts2的数据封装
- java字符串大小写转换的两种方法
- [150729]spring+websocket整合(springMVC+spring+MyBatis即SSM框架和websocket技术的整合)
- [LeetCode][Java] Sum Root to Leaf Numbers
- Java实现二分查找算法实例分析
- 应一个好友要求写一个SpringJDBC 的文章 , 介绍返回操作数据库最新id写法
- Java 通过反射调用方法
- mac android eclipse 配置问题
- Java基础学习总结(41)——JPA常用注解
- Java基础学习总结(41)——JPA常用注解
- Java基础学习总结(41)——JPA常用注解
- Java类加载器
- java使用ArrayList遍历及效率比较实例分析