2014-03-06 25 views
2

我無法將scala-reflect添加爲依賴項。我project/build.sbt看起來是這樣的:無法添加scala-reflect作爲依賴關係

//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

您確定,您在第一個列表中顯示'project/build.sbt',而不僅僅是'build.sbt'? – laughedelic

+0

@laughedelic絕對。 –

回答

5

由@laughedelic推測此問題。

build.sbt應該位於根目錄中。假設你正在寫在test-sbt項目,你應該結束了類似的結構:

test-sbt/build.sbt 
test-sbt/project 

否則build.sbt是創建由SBT使用的「內部編譯項目」使用。

更深入的解釋可以在SBT的文檔sbt is recursive中找到。

+0

Whay,我認爲它應該在項目目錄中,而不是在根目錄中。 –

相關問題