Flink 与 Scala IDE 和 SBT

Flink with Scala IDE and SBT

我正在处理我的第一个 Apache Flink wordcount 示例。 我的设置是 Scala IDE(Eclipse) 4.3.0、Scala 2.10.4、SBT 版本 0.13.8。

IDE 抛出错误 "can't expand macros compiled by previous versions of Scala" 来电 env.fromElements

val env = ExecutionEnvironment.getExecutionEnvironment
val text = env.fromElements("first line", "second line")

我能够使用 SBT 编译和生成程序集 jar。我什至可以 run/debug IDE 中的程序。只是 IDE 中的错误很烦人,它阻止了 IDE 功能,如自动完成等。我觉得它的某些设置需要调整。分不清是哪一个。有什么提示吗?

我的build.sbt

import AssemblyKeys._

name := "Flink Test"
version := "0.1.0"
organization := "com.NNN"
scalaVersion := "2.10.4"

javacOptions ++= Seq("-source", "1.7", "-target", "1.7")

libraryDependencies ++= Seq(
  "org.apache.flink" % "flink-scala" % "0.10.1" % "provided",
  "org.apache.flink" % "flink-clients" % "0.10.1" % "provided"
)

resolvers ++= Seq(
  "Akka"                    at "http://akka.io/repository/",
  "Sonatype"                at "https://oss.sonatype.org/"
)

assemblySettings

jarName in assembly := "flink-test.jar"

fork in run := true

assemblyOption in assembly :=  (assemblyOption in assembly).value.copy(includeScala = false)

更新

来自引用的链接

Notice that this means that the expansion of white-box macros is not currently possible in the compatibility 2.10 mode. Indeed, macros have known important recent developments between 2.10 and 2.11 which makes type checking compatibility between the two extremely difficult. If you have a significant project that uses 2.10 whitebox macros, you may want to look at 2.10 flavors of the Scala IDE.

Since whitebox macros have some incompatible improvements between 2.11 and 2.10, the IDE is not able to expand macros for you in compatibility mode. This probably will remain a long-term limitation of this mode. This is why the -Ymacro-expand:none setting works conjointly with the -Xsource:2.10 setting.

我想您将不得不使用旧版本的 scala IDE 或升级到 scala 2.11。 :(


似乎 Scala IDE (eclipse) 正在使用更高版本 (2.11) 来编译您的项目。尝试更改项目的编译器。

在 Scala IDE 中,转到

项目 > 属性 > Scala 编译器

如果需要,请选中使用项目设置

在 Scala 安装中,select 2.10 然后单击 确定

之后您可能需要清理并完全重建您的项目。

更多信息在这里: http://scala-ide.org/blog/scala-installations.html http://scala-ide.org/blog/Xsource-compatibility.html