如果我有一个事务管理类,其中有两个方法,例如
void OuterMethod(Data somedata)
{
this.InnerMethod(somedata)
}
@Transactional("mymanager")
void InnerMethod(Data somedata)
{
//writes some things
}
这有效吗?由于某种原因,我无法将其写入数据库,尽管它没有给我任何错误。
最佳答案
Spring does not use bytecode instrumentation to implement AOP. So it is predictable that if a method of a proxied object calls an other method in the same object, the aspect will not be applied on the method call. Spring allows however to apply the aspect on this method call by setting exposeProxy to True and using AopContext.currentProxy().
该信息可能有点过时,但据我所知,它仍然准确(但不确定“exposeProxy”标志)
关于java - Spring 事务管理 - 在哪里放置注释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3350659/