无法编译scala / SBT项目

时间:2016-07-06 07:57:00

标签: scala intellij-idea sbt

当我尝试运行(通过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安装scala安装之后),但无济于事。

1 个答案:

答案 0 :(得分:1)

scalaVersion := "2.11.8"

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

您不能使用为Scala 2.1.1编译的库和Scala 2.11。*。请改为使用某个版本"org.scalesxml" %% "scales-xml" %,这将寻找scales-xml_2.11。请参阅http://www.scala-sbt.org/0.13/docs/Cross-Build.html