您的位置:首页 > 编程语言 > Java开发

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里,则是
classpath:applicationContext.xml

如果是放在web-inf下,则是

@ContextConfiguration(locations = "classpath:file:src/main/webapp/WEB-INf/applicationContext.xml")
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: