Build.scala:1: 未找到:对象 sbt

Build.scala:1: not found: object sbt

我正在使用 sbt 1.0 版

$ sbt version
[info] Loading project definition from /Users/harit/code/learningScala/project
[info] Set current project to learningScala (in build file:/Users/harit/code/learningScala/)
[info] 1.0

我正在为我的项目使用 IntelliJ IDEA v14.1.3,结构看起来像

如您所见,该项目无法解析 Build。当我尝试使用命令行 运行 sbt 时,我看到

$ sbt 
[info] Loading project definition from /Users/harit/code/learningScala/project
[info] Set current project to learningScala (in build file:/Users/harit/code/learningScala/)
> compile
[info] Updating {file:/Users/harit/code/learningScala/}learningscala...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[info] Compiling 1 Scala source to /Users/harit/code/learningScala/target/scala-2.11/classes...
[error] /Users/harit/code/learningScala/Build.scala:1: not found: object sbt
[error] import sbt.Build
[error]        ^
[error] /Users/harit/code/learningScala/Build.scala:3: not found: type Build
[error] object MyBuild extends Build {
[error]                        ^
[error] two errors found
[error] (compile:compileIncremental) Compilation failed
[error] Total time: 2 s, completed May 28, 2015 8:10:37 PM
> 

我对 Scalasbt 很陌生,所以不知道它出了什么问题

MyBuild.scalaroot。它应该在 project 文件夹中。我做了那个改变,现在它起作用了。感谢 IRC 上的 tpolecat 帮助我

> compile
[success] Total time: 0 s, completed May 28, 2015 8:20:57 PM
> compile
[info] Updating {file:/Users/harit/code/learningScala/}learningscala...
[info] Resolving jline#jline;2.12.1 ...
[info] Done updating.
[success] Total time: 0 s, completed May 28, 2015 8:21:22 PM
> 

我有一个多项目 sbt 构建,其中两个项目在它们的 build.sbt 文件中声明了两个相同的 val。我将重复的 val (s) 作为 def 移动到根项目中的 Build.scala,错误停止了。在这里找到答案:https://github.com/sbt/sbt/issues/1465

示例:val samza_gid = "org.apache.samza" 在 build.sbt 文件中变为 def samza_gid = "org.apache.samza" 在 Build.scala 文件中。