如何解决“错误:scalac:在类文件‘package.class’中遇到对 scala.ScalaObject 的错误符号引用"?

编程入门 行业动态 更新时间:2024-10-28 05:15:46
本文介绍了如何解决“错误: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 的错误符号引用"?

本文发布于:2023-11-25 04:24:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1628309.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   如何解决   符号   文件   scalac

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!