@BeforeTransaction
@BeforeTransaction
註解用於指示被註解的 void
方法應該在事務開始之前執行,適用於那些使用 Spring 的 @Transactional
註解配置為在事務中執行的測試方法。@BeforeTransaction
方法不必是 public
的,並且可以在基於 Java 8 的介面預設方法上宣告。
以下示例展示瞭如何使用 @BeforeTransaction
註解
-
Java
-
Kotlin
@BeforeTransaction (1)
void beforeTransaction() {
// logic to be run before a transaction is started
}
1 | 在事務開始前執行此方法。 |
@BeforeTransaction (1)
fun beforeTransaction() {
// logic to be run before a transaction is started
}
1 | 在事務開始前執行此方法。 |