+-
java – 是否可以在Spring中从非事务方法调用事务方法?
假设我有一个Repository类.

@Repository class MyRepository { @Transactional void method1 () { // some logic here } void method2 () { // some logic here method1(); // some logic here } }

在String中可以这样做吗?这是如何工作的?

最佳答案
这不起作用,因为这是一个自我调用.看到
Spring @Transaction method call by the method within the same class, does not work?

根据您的应用程序及其职责,您可以为method2()创建另一个bean.
除此之外,DAO方法通常不应注释@Transactional.看到
Where does the @Transactional annotation belong?

点击查看更多相关文章

转载注明原文:java – 是否可以在Spring中从非事务方法调用事务方法? - 乐贴网