如何修复NoSuchMethodError? [英] How do I fix a NoSuchMethodError?

查看:140
本文介绍了如何修复NoSuchMethodError?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行Java程序时出现 NoSuchMethodError 错误。有什么问题,如何解决?

I'm getting a NoSuchMethodError error when running my Java program. What's wrong and how do I fix it?

推荐答案

没有更多信息,很难找出问题,但根本原因是你最有可能针对缺少方法的类的不同版本编译了一个类,而不是运行它时使用的类。

Without any more information it is difficult to pinpoint the problem, but the root cause is that you most likely have compiled a class against a different version of the class that is missing a method, than the one you are using when running it.

看看堆栈跟踪...如果在库中的对象上调用方法时出现异常,则在编译和运行时很可能使用库的单独版本。确保你在两个地方都有正确的版本。

Look at the stack trace ... If the exception appears when calling a method on an object in a library, you are most likely using separate versions of the library when compiling and running. Make sure you have the right version both places.

如果在你所做的类实例化的对象上调用方法时出现异常,那么你的构建过程似乎有缺陷。确保在编译时更新实际运行的类文件。

If the exception appears when calling a method on objects instantiated by classes you made, then your build process seems to be faulty. Make sure the class files that you are actually running are updated when you compile.

这篇关于如何修复NoSuchMethodError?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆