前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >构建Flink工程及demo演示

构建Flink工程及demo演示

作者头像
Spark学习技巧
发布2018-01-31 10:27:32
2.9K0
发布2018-01-31 10:27:32
举报
文章被收录于专栏:Spark学习技巧

1,要求

Maven 3.0.4以上版本

Java 7.x以上版本

2,构建maven工程

mvn archetype:generate \ -DarchetypeGroupId=org.apache.flink \ -DarchetypeArtifactId=flink-quickstart-scala \ -DarchetypeVersion=1.3.2

允许你重新给你的工程命名,执行该命令后需要输入groupId, artifactId, and package名。

3,检查导入项目

可以在生成的目录下查看工程目录结构

可以将该maven工程导入你的IDE编辑器。对于Eclipse,需要下面的几个插件,可以在线安装。

1),Eclipse 4.x

a) Scala IDE : http://download.scala-ide.org/sdk/lithium/e44/scala211/stable/site

b) m2eclipse-scala : http://alchim31.free.fr/m2e-scala/update-site

c) BuildHelper Maven Plugin :

https://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-buildhelper/0.15.0/N/0.15.0.201207090124/

2),Eclipse 3.8

a) Scala IDE for Scala 2.11 :

http://download.scala-ide.org/sdk/helium/e38/scala211/stable/site

Scala IDE for Scala 2.10 :

http://download.scala-ide.org/sdk/helium/e38/scala210/stable/site

b) m2eclipse-scala :

http://alchim31.free.fr/m2e-scala/update-site

c)Build Helper Maven Plugin

https://repository.sonatype.org/content/repositories/forge-sites/m2e-extras/0.14.0/N/0.14.0.201109282148/

IntelliJ IDE直接导入maven工程,然后引入scala插件即可。

4,运行测试

浪尖习惯用idea作为,导入工程后,可以看到

代码语言:js
复制
object WordCount {
 def main(args: Array[String]) {
 // set up the execution environment
 val env = ExecutionEnvironment.getExecutionEnvironment
 // get input data
 val text = env.fromElements("To be, or not to be,--that is the question:--",
 "Whether 'tis nobler in the mind to suffer", "The slings and arrows of outrageous fortune",
 "Or to take arms against a sea of troubles,")
 val counts = text.flatMap { _.toLowerCase.split("\\W+") }
      .map { (_, 1) }
      .groupBy(0)
      .sum(1)
 // execute and print result
 counts.print()

  }
}

直接可以在idea中运行,执行结果如下:

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2017-09-01,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 浪尖聊大数据 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档