apache flink无法解析导入

问题描述

您好,iam正在研究flink简介,但iam无法正确导入

import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.walkthrough.common.sink.AlertSink;
import org.apache.flink.walkthrough.common.entity.Alert;
import org.apache.flink.walkthrough.common.entity.Transaction;
import org.apache.flink.walkthrough.common.source.TransactionSource;

这些软件包无法导入 我已从以下网站link

使用过

在此链接中,我已经通过mvn命令导入了项目

请帮助我解决这个问题

解决方法

能否请您在Maven pom.xml中验证以下工件?

<dependency>
    <groupId>org.apache.flink</groupId>
    <artifactId>flink-streaming-java_2.12</artifactId>
    <version>1.11.0</version>
    <scope>provided</scope>
</dependency>

<dependency>
    <groupId>org.apache.flink</groupId>
    <artifactId>flink-walkthrough-table-java</artifactId>
    <version>1.11.1</version>
</dependency>

,

我自己尝试了一下,发现为了在IDE(IntelliJ)中运行该应用程序,我必须选择“运行/编辑配置”下的选项,以“包括具有“已提供”作用域的依赖项”。一旦这样做,一切都会很好。

enter image description here

我能够从命令行(通过“ mvn clean package”)构建应用程序而无需进行任何更改。