赞
踩
(1)通过实验掌握基本的Flink编程方法。
(2)掌握用IntelliJ IDEA工具编写Flink程序的方法。
(1)Ubuntu18.04(或Ubuntu16.04)。
(2)IntelliJ IDEA。
(3)Flink1.9.1。
(1)使用IntelliJ IDEA工具开发WordCount程序
在Linux系统中安装IntelliJ IDEA,然后使用IntelliJ IDEA工具开发WordCount程序,并打包成JAR文件,提交到Flink中运行。
- #启动Flink
-
- cd /usr/local/flink
-
- ./bin/start-cluster.sh
-
- #启动IntelliJ IDEA
-
- cd /usr/local/idea
-
- ./bin/idea.sh
在idea中创建FlinkTest项目,在Java包中编写WordCountData.java,WordCountTokenizer.java,WordCount.java
首先弄pom.xml,添加依赖
- <?xml version="1.0" encoding="UTF-8"?>
- <project xmlns="http://maven.apache.org/POM/4.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.example</groupId>
- <artifactId>FinkWordCount</artifactId>
- <version>1.0-SNAPSHOT</version>
-
- <properties>
- <maven.compiler.source>8</maven.compiler.source>
- <maven.compiler.target>8</maven.compiler.target>
- </properties>
-
- <dependencies>
- <!-- https://mvnrepository.com/artifact/org.apache.flink/flink-java -->
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-java</artifactId>
- <version>1.9.1</version>
- </dependency>
- <!-- https://mvnrepository.com/artifact/org.apache.flink/flink-streaming-java -->
- <dependency>
- <groupId>org.apache.flink</groupId>
- <artifactId>flink-streaming-java_2.12</artifactId>
- <version>1.9.1</version>
- <scope>provided</scope>
- </dependency>
- <!-- https://mvnrepository.com/artifact/org.apache.flink/flink-clients -->
- <dependency>
- <groupId>

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。