6
我作为单元测试运行,即使在春季3.1中不使用@rollback
,它也会自动返回。 我的测试看起来像@Transactional是否会在Spring 3中自动回滚事务?
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:application-context.xml" })
public class PersonServiceTest {
@Test
@Transactional
public void savePerson() {
Person person = createPerson();
personService.savePerson(person);
}
}
回滚行为是否默认设置?
TL; DR:是的,这是默认设置。 – 2015-08-15 03:21:35