【问题标题】:Can't compile scala/SBT project无法编译 scala/SBT 项目
【发布时间】:2016-07-06 07:56:59
【问题描述】:

当我尝试运行(通过 SBT)我的 scala 程序时,我遇到了一堆错误。

摘录如下:

[error] missing or invalid dependency detected while loading class file 'IterableUtils.class'.
[error] Could not access type ScalaObject in package scala,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)
[error] A full rebuild may help if 'IterableUtils.class' was compiled against an incompatible version of scala.
[error] missing or invalid dependency detected while loading class file 'AsBooleanTrait.class'.
[error] Could not access type ScalaObject in package scala,
[error] because it (or its dependencies) are missing. Check your build definition for
[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` to see the problematic classpath.)

.....

我确实将 scala-library.jar 添加到类路径中,但无济于事。有谁知道可能缺少什么?

附言。使用 -> osx 上的新 SBT 项目(Intellij)

编辑:这是 build.sbt

name := "test"

version := "1.0"

scalaVersion := "2.11.8"

resolvers += "Scales XML" at "https://mvnrepository.com/artifact/org.scalesxml/scales-xml_2.9.1"

libraryDependencies += "org.scalesxml" % "scales-xml_2.9.1" % "0.3-RC7"

SBT 是 0.13.8 版本

编辑 2:

想通了。我试图在不创建实例的情况下运行一个类(使用 main 方法)......在将其更改为 Object 之后,事情会变得更好:)

编辑 3:

说得太早了。我发现它与在 build.sbt 中设置 scalaVersion 有关。当我把整行都去掉时,它不再抱怨缺少依赖项。当我把它放回去时,我得到了上面提到的错误。我也尝试将其设置为 2.11.7(在使用 brew install scala 安装之后)但无济于事。

【问题讨论】:

  • 您可以编辑您的帖子并添加您的build.sbt 文件吗?
  • 您选择了哪些版本的 SDK、SBT 和 Scala?
  • 按要求更新
  • 你用什么命令来运行你的项目?
  • 'sbt run' 在终端中

标签: scala intellij-idea sbt


【解决方案1】:
scalaVersion := "2.11.8"

libraryDependencies += "org.scalesxml" % "scales-xml_2.9.1" % "0.3-RC7"

您不能将针对 Scala 2.9.1 编译的库与 Scala 2.11.* 一起使用。改为写"org.scalesxml" %% "scales-xml" % some-version,它将寻找scales-xml_2.11。见http://www.scala-sbt.org/0.13/docs/Cross-Build.html

【讨论】:

    猜你喜欢
    • 2020-08-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-20
    • 1970-01-01
    • 1970-01-01
    • 2013-05-24
    • 1970-01-01
    相关资源
    最近更新 更多