当前位置:   article > 正文

Flink初级编程实践_(1)使用intellij idea工具开发wordcount程序 在linux系统中安装intel

(1)使用intellij idea工具开发wordcount程序 在linux系统中安装intellij idea,然


实验7

Flink初级编程实践

1.实验目的

(1)通过实验掌握基本的Flink编程方法。

(2)掌握用IntelliJ IDEA工具编写Flink程序的方法。

2.实验平台

(1)Ubuntu18.04(或Ubuntu16.04)。

(2)IntelliJ IDEA。

(3)Flink1.9.1。

3.实验步骤

(1)使用IntelliJ IDEA工具开发WordCount程序

在Linux系统中安装IntelliJ IDEA,然后使用IntelliJ IDEA工具开发WordCount程序,并打包成JAR文件,提交到Flink中运行。

  1. #启动Flink
  2. cd /usr/local/flink
  3. ./bin/start-cluster.sh
  4. #启动IntelliJ IDEA
  5. cd /usr/local/idea
  6. ./bin/idea.sh

在idea中创建FlinkTest项目,在Java包中编写WordCountData.java,WordCountTokenizer.java,WordCount.java

首先弄pom.xml,添加依赖

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  5. <modelVersion>4.0.0</modelVersion>
  6. <groupId>org.example</groupId>
  7. <artifactId>FinkWordCount</artifactId>
  8. <version>1.0-SNAPSHOT</version>
  9. <properties>
  10. <maven.compiler.source>8</maven.compiler.source>
  11. <maven.compiler.target>8</maven.compiler.target>
  12. </properties>
  13. <dependencies>
  14. <!-- https://mvnrepository.com/artifact/org.apache.flink/flink-java -->
  15. <dependency>
  16. <groupId>org.apache.flink</groupId>
  17. <artifactId>flink-java</artifactId>
  18. <version>1.9.1</version>
  19. </dependency>
  20. <!-- https://mvnrepository.com/artifact/org.apache.flink/flink-streaming-java -->
  21. <dependency>
  22. <groupId>org.apache.flink</groupId>
  23. <artifactId>flink-streaming-java_2.12</artifactId>
  24. <version>1.9.1</version>
  25. <scope>provided</scope>
  26. </dependency>
  27. <!-- https://mvnrepository.com/artifact/org.apache.flink/flink-clients -->
  28. <dependency>
  29. <groupId>
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/在线问答5/article/detail/751882
推荐阅读
相关标签
  

闽ICP备14008679号