在 groovy 中使用事务注释时遇到问题
有没有人有过 Spring 事务(类级、代理、注释驱动)的经验,但没有在 Groovy 类中开始?我一直在与无法解释的 LazyInitialization 异常作斗争,注意到堆栈跟踪不包含启动事务的调用。听起来很疯狂,但我想知道 Groovy 是否接受了事务注释。
Has anyone had any experience with Spring transactions (class-level, with proxy, annotation-driven) not getting started in a Groovy Class? I've been struggling with an unexplained LazyInitialization exception noticed that stacktrace does not include a call to start the transaction. Sounds crazy but I have to wonder whether Groovy picks up on the Transactional annotation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
事实上我找到了问题的根源。来自 Spring 文档(我强调添加):
我的问题是我使用的是基于类的代理。
Actually I found the source of the problem. From the Spring documentation (i added in emphasis):
My problem was that I was using class-based proxies.
如果您正在使用 Grails,您可以尝试使用
它来替代事务注释。如果代码使用这种方法,那么您可以确定注释是问题的原因(尽管我知道您可能不喜欢将此作为永久解决方案)。
If you're using Grails, you could try using
as an alternative to the transactional annotation. If the code works with this approach, then you can be sure that it's the annotation that's the cause of the problem (though I understand you may not like this as a permanent solution).