我怎样才能让我的CGLIB代理类与spring框架的ReflectionUtils一起工作?

发布于 2024-09-06 19:03:15 字数 177 浏览 4 评论 0原文

我有一个 cglib 代理类,因为该实现同时使用 @Repository @Transactional 注释。

我想使用 spring 的反射实用程序来设置字段值以模拟其中一个字段。

但是当反射utils在我的类中找不到该字段时。

我怎样才能让它发挥作用?这样我就可以模拟这个领域(合作者)。

I have a cglib proxied class because the impl uses both the @Repository @Transactional annotations.

I would like to use spring's reflection utils to set the field value for mocking out one of the fields.

But when reflection utils can not find the field in my class.

How can i get this to work? So then i can mock out the field (collaborator).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一念一轮回 2024-09-13 19:03:15

CGLIB 扩展您的类并在扩展类中添加事务逻辑。您是否尝试过使用受保护字段而不是私有字段?

CGLIB extends your class and adds the transactional logic in the extended class. Have you tried to use protected fields instead of private?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文