gpt4 book ai didi

java - Spring 事务管理 - 在哪里放置注释?

转载 作者:行者123 更新时间:2023-12-02 08:31:05 24 4
gpt4 key购买 nike

如果我有一个事务管理类,其中有两个方法,例如

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”标志)

参见http://forum.springsource.org/showthread.php?t=9926

关于java - Spring 事务管理 - 在哪里放置注释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3350659/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com