简体   繁体   English

通过Scala IDE和SBT进行链接

[英]Flink with Scala IDE and SBT

I'm working on my first Apache Flink wordcount example. 我正在研究我的第一个Apache Flink wordcount示例。 My setup is Scala IDE(Eclipse) 4.3.0, Scala 2.10.4, SBT version 0.13.8. 我的设置是Scala IDE(Eclipse)4.3.0,Scala 2.10.4,SBT版本0.13.8。

IDE throws error "can't expand macros compiled by previous versions of Scala" for the call env.fromElements IDE为调用env.fromElements引发错误“无法扩展Scala早期版本编译的宏”

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

I able to compile and generate assembly jar with SBT. 我能够使用SBT编译并生成程序集jar。 I'm even able to run/debug the program in IDE. 我什至可以在IDE中运行/调试程序。 Its just that the error in IDE is annoying and it prevents IDE feature like auto complete, etc. I have a felling its some setting that needs to be tweaked. 只是IDE中的错误很烦人,并且阻止了诸如自动完成之类的IDE功能。我降低了某些需要调整的设置。 Can't figure out which one. 不知道是哪一个。 Any hints? 有什么提示吗?

My build.sbt 我的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)

UPDATE UPDATE

From the referenced links 从引用的链接

Notice that this means that the expansion of white-box macros is not currently possible in the compatibility 2.10 mode. 请注意,这意味着在兼容2.10模式下当前无法扩展白盒宏。 Indeed, macros have known important recent developments between 2.10 and 2.11 which makes type checking compatibility between the two extremely difficult. 确实,宏已经知道了2.10和2.11之间的重要最新进展,这使得两者之间的类型检查兼容性非常困难。 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. 如果您有一个使用2.10白盒宏的重要项目,则可能需要查看Scala IDE的2.10版本。

and

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. 由于白盒宏在2.11和2.10之间具有一些不兼容的改进,因此IDE无法在兼容模式下为您扩展宏。 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. 这就是-Ymacro-expand:none设置与-Xsource:2.10设置共同起作用的原因。

I guess you will have to use an older version of scala IDE or upgrade to scala 2.11. 我猜您将不得不使用旧版本的Scala IDE或升级到Scala 2.11。 :( :(


It seems Scala IDE (eclipse) is using a greater version (2.11) to compile your project. 看来Scala IDE(eclipse)正在使用更高版本(2.11)来编译您的项目。 Try to change the project's compiler. 尝试更改项目的编译器。

In Scala IDE, go to 在Scala IDE中,转到

Project > Propertiers > Scala Compiler 项目>属性> Scala编译器

If needed, check Use Project Settings 如果需要,请选中“ 使用项目设置”

In Scala Installation, select 2.10 and click Ok . 在Scala安装中,选择2.10 ,然后单击确定

Maybe you need to clean and full rebuild your project after that. 之后,您可能需要清理并完全重建项目。

More info here: http://scala-ide.org/blog/scala-installations.html http://scala-ide.org/blog/Xsource-compatibility.html 此处提供更多信息: http : //scala-ide.org/blog/scala-installations.html http://scala-ide.org/blog/Xsource-compatibility.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM