我无法添加scala-reflect
作为依赖项。我的project/build.sbt
看起来像这样:
//the name of the project, will become the name of the war file when you run the package command.
name := "Test-SBT"
version := "1.0"
//specify which Scala version we are using in this project.
scalaVersion := "2.10.3"
libraryDependencies <++= (scalaVersion)(sv =>
Seq(
"org.scala-lang" % "scala-reflect" % "2.10.3",
"org.scala-lang" % "scala-compiler" % "2.10.3"
)
)
project/build.properties
sbt.version=0.13.0
这是我的主要课程:
object Main1 extends App {
import scala.reflect.runtime.universe
val runtimeMirror = universe.runtimeMirror(getClass.getClassLoader)
//......
}
它说object runtime is not a member of package reflect
。当然,我做了“gen-idea”,“clean”等事情。怎么了?
答案 0 :(得分:5)
由于@laughedelic的问题而猜到这里。
build.sbt应该在root中。假设您正在编写的项目位于test-sbt
,您应该得到类似于以下结构:
test-sbt/build.sbt
test-sbt/project
否则build.sbt
用于创建SBT使用的“内部编译项目”。
可以在SBT的文档sbt is recursive中找到更深入的解释。