【发布时间】:2014-04-09 21:46:07
【问题描述】:
有没有办法在 Spring 中访问当前事务?我的目标是在事务启动时向事务添加一些信息,并在同一事务中的所有方法调用中使用该信息。
这是 EJB 的解决方案:How can i attach data to a JTA transaction? (or uniquely identify it) 我正在寻找与 spring 相同的解决方案。
【问题讨论】:
-
在你的服务类中使用@Inject 来注入事务。
-
@Braj 但这并不表示如何将对象添加到事务中。
-
但它回答了你的第一个问题
Is there a way to access the current transaction in Spring ?
标签: java spring transactions