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

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

问题描述

选择打开或导入"并选择examples-scala/"文件夹.项目导入时没有机会选择选项.

现在我有一个项目

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

错误

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

如何在 IntelliJ 中运行此代码?

解决方案

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

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.

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.

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.

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?

Here are steps to reproduce

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

Start IntelliJ

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

Now I have a project

Browse to AverageSensorReadings class, open, and run.

Errors with

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

How can I run this code in IntelliJ?

解决方案

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天全站免登陆