sbt Scala项目中的错误

时间:2014-07-05 20:01:42

标签: macos scala sbt osx-mavericks

创建一个示例Scala项目结构(在我的基于OS X Mavericks的计算机上),如下所示:

在sample_project目录中:

src
    main
      java
      scala
        Hello.scala
      resources
    test
      java
      scala
      resources
 build.sbt

Hello.scala:

object Hello {
    def main(args: Array[String]) = println("Hello!")
}

build.sbt:

name := "hello"

version := "1.0"

scalaVersion := "2.11.1"

将build.properties放在sample_project / project下:

sbt.version=0.13.5

当我尝试使用" sbt"根文件夹中的命令:

/sample_project $ sbt
Getting org.scala-tools.sbt sbt_2.8.1 0.13.5 ...

:: problems summary ::
:::: WARNINGS
        module not found: org.scala-tools.sbt#sbt_2.8.1;0.13.5

    ==== local: tried

      .ivy2/local/org.scala-tools.sbt/sbt_2.8.1/0.13.5/ivys/ivy.xml

      -- artifact org.scala-tools.sbt#sbt_2.8.1;0.13.5!sbt_2.8.1.jar:

      .ivy2/local/org.scala-tools.sbt/sbt_2.8.1/0.13.5/jars/sbt_2.8.1.jar

    ==== Maven2 Local: tried

      file://.m2/repository/org/scala-tools/sbt/sbt_2.8.1/0.13.5/sbt_2.8.1-0.13.5.pom

      -- artifact org.scala-tools.sbt#sbt_2.8.1;0.13.5!sbt_2.8.1.jar:

      file://.m2/repository/org/scala-tools/sbt/sbt_2.8.1/0.13.5/sbt_2.8.1-0.13.5.jar

    ==== typesafe-ivy-releases: tried

      http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt_2.8.1/0.13.5/ivys/ivy.xml

      -- artifact org.scala-tools.sbt#sbt_2.8.1;0.13.5!sbt_2.8.1.jar:

      http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt_2.8.1/0.13.5/jars/sbt_2.8.1.jar

    ==== Maven Central: tried

      http://repo1.maven.org/maven2/org/scala-tools/sbt/sbt_2.8.1/0.13.5/sbt_2.8.1-0.13.5.pom

      -- artifact org.scala-tools.sbt#sbt_2.8.1;0.13.5!sbt_2.8.1.jar:

      http://repo1.maven.org/maven2/org/scala-tools/sbt/sbt_2.8.1/0.13.5/sbt_2.8.1-0.13.5.jar

    ==== Scala-Tools Maven2 Repository: tried

      http://scala-tools.org/repo-releases/org/scala-tools/sbt/sbt_2.8.1/0.13.5/sbt_2.8.1-0.13.5.pom

      -- artifact org.scala-tools.sbt#sbt_2.8.1;0.13.5!sbt_2.8.1.jar:

      http://scala-tools.org/repo-releases/org/scala-tools/sbt/sbt_2.8.1/0.13.5/sbt_2.8.1-0.13.5.jar

    ==== Scala-Tools Maven2 Snapshots Repository: tried

      http://scala-tools.org/repo-snapshots/org/scala-tools/sbt/sbt_2.8.1/0.13.5/sbt_2.8.1-0.13.5.pom

      -- artifact org.scala-tools.sbt#sbt_2.8.1;0.13.5!sbt_2.8.1.jar:

      http://scala-tools.org/repo-snapshots/org/scala-tools/sbt/sbt_2.8.1/0.13.5/sbt_2.8.1-0.13.5.jar

        ::::::::::::::::::::::::::::::::::::::::::::::

        ::          UNRESOLVED DEPENDENCIES         ::

        ::::::::::::::::::::::::::::::::::::::::::::::

        :: org.scala-tools.sbt#sbt_2.8.1;0.13.5: not found

        ::::::::::::::::::::::::::::::::::::::::::::::

:: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
unresolved dependency: org.scala-tools.sbt#sbt_2.8.1;0.13.5: not found
Error during sbt execution: Error retrieving required libraries
  (see sample_project/project/boot/update.log for complete log)
Error: Could not retrieve sbt 0.13.5

2 个答案:

答案 0 :(得分:0)

这看起来像sbt版本不匹配。在project下创建一个sample_project目录,在其中创建一个名为build.properties的文件,其中包含以下内容:

sbt.version=0.13.5

答案 1 :(得分:0)

您似乎有一个旧的启动器版本的sbt,可能甚至太旧而无法应对新的0.13.5

尝试update您的启动器到最新版本。在MacOS上,最简单的方法是使用Homebrew包管理器。如果尚未完成,请使用以下命令安装:

$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

然后,安装sbt

$ brew install sbt