- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
为什么在没有Exception
的情况下事务被回滚?对象未被保存。我定义了如下交易参数:
@Transactional(value = "transactionManager", timeout = 30, rollbackFor =
java.lang.Exception.class)`.
这是日志对事务的描述。
org.springframework.test.context.transaction.TransactionalTestExecutionListener
endTransaction
INFO: Rolled back transaction after test execution for test context [TestContext@51e2a069
testClass = DAOTest, testInstance = sample.library.dao.DAOTest@7591777e, testMethod =
testSaveDao@DAOTest, testException = [null], mergedContextConfiguration =
[MergedContextConfiguration@213c2d7f testClass = DAOTest, locations =
'{classpath:/applicationcontext.xml}', classes = '{}', contextInitializerClasses = '[]',
activeProfiles = '{}', contextLoader =
'org.springframework.test.context.support.DelegatingSmartContextLoader', parent =
[null]]]
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.634 sec
这是 DAOTest
类的完整日志:
-------------------------------------------------------------------------------
Test set: sample.library.dao.DAOTest
-------------------------------------------------------------------------------
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.634 sec
哪里做错了?如有必要,我可以提供更多信息。
最佳答案
INFO
级别应该提示这不是错误消息。无论服务级别方法的主要设置如何,默认情况下您的测试都会回滚。为了避免回滚(如果你真的想要),你需要在测试类本身上添加注释,如 Annotations section of the Testing chapter 中所述。在 Spring 文档中。有问题的注释是 @Rollback
。
关于java - Spring transactionManager 正在回滚,而 testexception=[null]!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19333955/
我正在尝试测试以下类(class): package com.myclass; public class MyClass { private Map dataMap = new HashMap
我正在尝试运行以下测试。在本例中,只是一个空白测试来尝试一下,但由于某种原因它不起作用。 @RunWith(SpringJUnit4ClassRunner.class) @ContextConfigu
为什么在没有Exception 的情况下事务被回滚?对象未被保存。我定义了如下交易参数: @Transactional(value = "transactionManager", timeout =
问题出在 LINUX 中的 SonarQube 4.0 - Linux 中 SonarQube 4.0 的另一个问题 - 出现错误 - 由:资源的重复源引起 这是由于相同的 java 文件具有相同的完
我是一名优秀的程序员,十分优秀!