【问题标题】:Couldn't set up a simple scala project无法建立一个简单的 scala 项目
【发布时间】:2016-09-21 17:34:16
【问题描述】:

我已经有几年没有编写代码了,现在正试图重新投入到游戏中。我正在尝试设置一个非常简单的 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.8sbt 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!")
    }
}

【问题讨论】:

  • WFM。 eclipse 命令运行。这是好消息还是坏消息?当 sbt 最终尝试编译时,你会在你的代码中发现两个错误。
  • 是否需要解析器?我建议安装激活器并运行activator new:lightbend.com/community/core-tools/activator-and-sbt
  • 是的,我通过从 project_folder/project/plugins.sbt 中删除 addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0") 并放入 ~ /.sbt/0.13/plugins/plugins.sbt 文件。

标签: eclipse scala sbteclipse


【解决方案1】:

问题与 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.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-26
    • 1970-01-01
    • 1970-01-01
    • 2011-02-17
    • 2018-11-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多