装箱拆箱、cglib、spring 和 NoSuchMethodError 之谜

发布于 2024-10-07 19:05:23 字数 508 浏览 0 评论 0 原文

我在我的项目中使用 Spring 和 GWt。在少数情况下,当我调用 spring bean 代理的方法时,CGLIB 会抛出 NoSuchMethodError

如果我查看错误,它会告诉我它尝试查找带有 Integer 对象而不是基本 int 字段的方法。

例如,我有一个在我的 spring bean 中定义的方法,

public void saveObject(int value)
{
// some stuff
}

当我调用此方法时,会抛出错误: NoSuchMethodError ,这表明它尝试查找方法 saveObject > 有一个字段 java.lang.Integer 而不是一个基本的 int 字段(带有 I 键)

有什么问题?是否存在装箱/拆箱问题?我精确地说,我使用基本 int 而不是 Integer 来调用此方法。

I use Spring and GWt in my project. In few cases I've got a NoSuchMethodError thrown by CGLIB when I invoke a method of a spring bean proxy.

If I look at the error, It shows me that it tries to find a method with Integer object instead basic int fields.

For example, I've got a method which is defined like that in my spring bean

public void saveObject(int value)
{
// some stuff
}

When I call this method an error is thrown : NoSuchMethodError which indicates it tries to find method saveObject with a field java.lang.Integer and not a basic int field (with I key)

What's the problem ? is there boxing/unboxing problems ? I precise that I call this method with a basic int and not an Integer.

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

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

发布评论

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

评论(1

千仐 2024-10-14 19:05:23

你在使用 cglib-nodep 吗?这在过去对我有用。另请检查您正在使用的 cglib 版本并尝试使用最新版本。

Are you using cglib-nodep? That has worked for me in the past. Also check the version of cglib that you are using and try to use the latest one.

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