无法设置简单的scala项目

时间:2016-09-20 17:43:42

标签: eclipse scala sbteclipse

我几年没有编码,现在又想回到游戏中。我试图建立一个非常简单的scala项目 HelloWorld ,并在尝试从sbt控制台编译时收到以下错误消息。我正在添加 sbteclipse 插件来生成eclipse项目设置。

[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.typesafe.sbteclipse#sbteclipse-plugin;4.0.0: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn]  Note: Some unresolved dependencies have extra attributes.  Check that these dependencies exist with the requested attributes.
[warn]      com.typesafe.sbteclipse:sbteclipse-plugin:4.0.0 (scalaVersion=2.11, sbtVersion=0.13)
[warn]
[warn]  Note: Unresolved dependencies path:
[warn]      com.typesafe.sbteclipse:sbteclipse-plugin:4.0.0 (scalaVersion=2.11, sbtVersion=0.13) (/Users/michael/Development/Scala-Testings/HelloWorld/project/plugins.sbt#L3-4)
[warn]        +- default:helloworld-build:0.1-SNAPSHOT (scalaVersion=2.11, sbtVersion=0.13)
sbt.ResolveException: unresolved dependency: com.typesafe.sbteclipse#sbteclipse-plugin;4.0.0: not found

我在macOS Sierra上使用brew安装的 scala版本2.11.8 sbt 0.13.12

项目目录结构

src
+- main
   +- scala
      +- HelloWorld.scala
project
+- plugins.sbt
build.sbt

build.sbt的内容

name := "HelloWorld"

version := "1.0"

scalaVersion := "2.11.8"

plugins.sbt的内容

logLevel := Level.Warn

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")

HelloWorld.scala的内容

object HelloWorld extends App {
    def main (args Array[String]) : Unit = {
        println ("HelloWorld!")
    }
}

1 个答案:

答案 0 :(得分:0)

问题与sbt版本0.13.12有关,它是用Scala版本2.10.x编译的,而我安装了Scala 2.11.8。

我通过移除

来实现它
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")

project_folder/project/plugins.sbt

并输入

~/.sbt/0.13/plugins/plugins.sbt file.