Spring测试中插入后的java回滚
我正在对我的spring应用程序进行测试,在测试应用程序的同时将数据插入db。 但我不知道如何回退
测试代码:
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:/META-INF/spring.cfg.xml")
public class SpringAppTest{
@Autowired
private MyService myService;
@BeforeClass
public static void setUpClass() throws Exception {
}
@AfterClass
public static void tearDownClass() throws Exception {
}
@Test
public void testInsert(){
//insert code
}
}
请引导我
# 1 楼答案
在上课前使用以下注释:
这里txManager是应用程序上下文的事务管理器
这里txManager是应用程序上下文中事务管理器的实例或bean id