scala 如何修复 NoSuchMethodError?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13098856/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 04:40:41  来源:igfitidea点击:

How to fix NoSuchMethodError?

scalatesting

提问by user1779032

I use Scala 2.10.0RC1 and sbt 0.12.1. What causes and how can I fix this runtime error (runs fine on 2.9.2)?

我使用 Scala 2.10.0RC1 和 sbt 0.12.1。是什么原因以及如何修复此运行时错误(在 2.9.2 上运行良好)?

The exact error message is:

确切的错误消息是:

java.lang.NoSuchMethodError: scala.Predef$ArrowAssoc$.extension$$minus$greater(Ljava/lang/Object;Ljava/lang/Object;)Lscala/Tuple2;

java.lang.NoSuchMethodError: scala.Predef$ArrowAssoc$.extension$$minus$greater(Ljava/lang/Object;Ljava/lang/Object;)Lscala/Tuple2;

回答by iwein

You're running the code with the wrong Scala version. This can have several causes:

您正在使用错误的 Scala 版本运行代码。这可能有多种原因:

  • misconfiguration of the project with sbt – search for 2.9.2 in config files
  • stale cache used by sbt – sbt reboot
  • something else?
  • 使用 sbt 错误配置项目 – 在配置文件中搜索 2.9.2
  • sbt 使用的陈旧缓存 – sbt reboot
  • 还有什么?

If you meticulously check all your sbt configuration files for 2.9.2 and then wipe out all caches, things should run better. Dependencies usually have a version number in the name of the jar file, so running a find on your system will likely point you to the ones you missed.

如果您仔细检查 2.9.2 的所有 sbt 配置文件,然后清除所有缓存,事情应该会运行得更好。依赖项通常在 jar 文件的名称中包含一个版本号,因此在您的系统上运行 find 可能会指向您错过的那些。