如何解决“错误:scalac:在类文件‘package.class’中遇到对 scala.ScalaObject 的错误符号引用"? [英] How to troubleshoot "Error:scalac: bad symbolic reference to scala.ScalaObject encountered in class file 'package.class'"?

查看:44
本文介绍了如何解决“错误:scalac:在类文件‘package.class’中遇到对 scala.ScalaObject 的错误符号引用"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试运行项目时遇到此错误消息:

I face this error message when I try to run the project:

Error:scalac: bad symbolic reference to scala.ScalaObject encountered in class file 'package.class'.
Cannot access type ScalaObject in package scala. The current classpath may be
missing a definition for scala.ScalaObject, or package.class may have been compiled against a version that's incompatible with the one found on the current classpath.

有类似的问题这里此处,但似乎没有一个适用于我的情况-我的不会吐出此类消息.我唯一要做的就是 scalaObject.

There are similar questions here and here, but none seems to be applicable to my case - mine isn't spitting out such messages. The only thing I have to go one is scalaObject.

这是一个突然的故障——该项目是在 IntelliJ IDEA 中使用 sbt 制作的,并且一直运行到今天.突然,它找不到它需要的东西.

This is a sudden breakage -- the project was made inside IntelliJ IDEA with sbt and ran find until today. Suddenly, it can't find what it needs.

这是整个build.sbt文件:

name := "MyApp"

libraryDependencies ++= Seq(
  "joda-time" % "joda-time"    % "2.3",
  "org.joda"  % "joda-convert" % "1.6",
  "org.scala-lang" % "scala-swing" % "2.9.2",

我该如何解决这个问题?

How do I troubleshoot this?

推荐答案

您提到您正在使用 IntelliJ IDEA.我正在为 Eclipse 使用 Scala IDE,但遇到了这个错误.它仅在我在 IDE 配置中关闭此选项时发生:

You mentioned that you are using IntelliJ IDEA. I am using the Scala IDE for Eclipse and I ran across this error. It only occurred when I turned off this option in the IDE config:

withVersionClasspathValidator - 检查类路径中 jar 的 Scala 兼容性

withVersionClasspathValidator - Check Scala compatibility of jars in classpath

当这个选项被打开时,我得到了:

When this option was turned on, I instead got:

mongo-casbah-commons_2.8.1-2.1.2.jar 与不兼容的 Scala (2.8.1) 版本交叉编译.

mongo-casbah-commons_2.8.1-2.1.2.jar is cross-compiled with an incompatible version of Scala (2.8.1).

我是 Scala 的新手,但这似乎是因为我使用 Scala 2.11.2 进行编译,但我包含了一个使用 Scala 2.8.1 构建的 jar.

I'm new to Scala, but this seems to be because I'm using Scala 2.11.2 to compile, but I'm including a jar that was built using Scala 2.8.1.

这篇关于如何解决“错误:scalac:在类文件‘package.class’中遇到对 scala.ScalaObject 的错误符号引用"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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