“使用Apache Flink进行流处理";如何从IntelliJ运行书籍代码? [英] "Stream Processing with Apache Flink" how to run book code from IntelliJ?

查看:53
本文介绍了“使用Apache Flink进行流处理";如何从IntelliJ运行书籍代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这篇文章中所述,我无法执行成功运行《用Apache Flink进行流处理》一书中的任何代码,包括预编译的jar.

As described in this post I have been unable to successfully run any code from the book "Stream Processing with Apache Flink, including the precompiled jar.

使用IDE并不是我的习惯,但是我认为我会尝试使用IntelliJ作为第3章在IDE中运行和调试Flink应用程序"介绍如何针对本书的代码进行专门的操作.

It is not my practice to use an IDE but I thought I would try to use IntelliJ as Chapter 3 "Run and Debug Flink Applications in an IDE" describes how to do that specifically for the code for this book.

这本书描述了我尚未找到使用方法的项目导入过程.它描述了导入时的设置选项,例如选择Maven.我还没有找到一种在导入中设置任何选项的方法.

The book describes a project import process that I have not found a way to use. It describes setting options on import, for example select Maven. I have not found a way to set any options on import.

我能够导入一个项目并运行代码.代码失败,看起来像缺少依赖项.也许因为它不是Maven项目?

I am able to import a project and run code. The code fails, looks like with missing dependency. Maybe because it isn't a Maven project?

以下是复制步骤

git clone https://github.com/streaming-with-flink/examples-scala.git

启动IntelliJ

Start IntelliJ

选择打开或导入",然后选择"examples-scala/"文件夹.该项目将导入,没有机会选择选项.

Choose "Open or Import" and Select the "examples-scala/" folder. The project imports with no chance to select options.

现在我有一个项目

浏览到AverageSensorReadings类,打开并运行.

Browse to AverageSensorReadings class, open, and run.

错误

java.lang.NoClassDefFoundError: org/apache/flink/api/common/typeinfo/TypeInformation

如何在IntelliJ中运行此代码?

How can I run this code in IntelliJ?

推荐答案

我看到flink依赖在Maven中具有provided范围-这意味着在运行应用程序时,thay不包含在类路径中.该应用程序很可能要在已经存在这些依赖项的环境(例如Hadoop)上运行.为了能够从IDE集中运行它,请在运行配置中在提供的"作用域中包括依赖项选项:

I see that flink dependencies have provided scope in Maven - this means that thay are not included into the classpath when you running the application. Most likely the application is meant to be run on environment where these dependencies already exist (e.g. Hadoop). To be able to run it from from IDE set Include dependencies with "Provided" scope option in Run Configuration:

这篇关于“使用Apache Flink进行流处理";如何从IntelliJ运行书籍代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆