我有一个非常大的类,其中包含很多方法。 我想仅忽略一种方法的回滚。我知道我们可以在类级别中设置它,如下所示,但我不需要所有方法: 有办法做到吗?
@TransactionConfiguration(transactionManager="transactionManager", defaultRollback=false)
@Transactional
public class TestPersistence {
@Test
void testBasicLogCreation(){
}
}
最佳答案
这个注释应该可以做到。
@Rollback(false)
@Rollback is a test annotation that is used to indicate whether a test-managed transaction should be rolled back after the test method has completed.
更多信息请参见 javaDoc .
关于java - 如何将 JUnit 测试类中的一个方法的回滚设置为 false?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37269750/