对象流不是包org.apache.flink.test的成员

问题描述 投票:1回答:3

我从github git clone flink代码,并用Intellij Idea打开它,我没有在IJ或代码中做任何配置(我已经安装了IJ scala插件并安装了scala sdk),我直接去运行以下两个Intellij Idea中的示例

我能够成功运行批处理模式字数计数示例(代码是类org.apache.flink.examples.scala.wordcount.WordCount in flink-examples-batch_2.11模块)。

但是当我尝试运行流式字数统计示例(代码是类org.apache.flink.streaming.scala.examples.wordcount.WordCount in flink-examples-streaming_2.11模块)时,我收到了很多编译错误:

Error:(30, 30) object streaming is not a member of package org.apache.flink.test
import org.apache.flink.test.streaming.runtime.util.TestListResultSink
Error:(46, 36) not found: type TestListResultSink
    val sideOutputResultSink = new TestListResultSink[String]
Error:(47, 26) not found: type TestListResultSink
    val resultSink = new TestListResultSink[Int]
Error:(82, 36) not found: type TestListResultSink
    val sideOutputResultSink = new TestListResultSink[String]
Error:(83, 26) not found: type TestListResultSink
    val resultSink = new TestListResultSink[Int]
Error:(119, 36) not found: type TestListResultSink
    val sideOutputResultSink = new TestListResultSink[String]
Error:(120, 26) not found: type TestListResultSink
    val resultSink = new TestListResultSink[Int]
Error:(152, 26) not found: type TestListResultSink
    val resultSink = new TestListResultSink[String]
Error:(153, 30) not found: type TestListResultSink
    val lateResultSink = new TestListResultSink[(String, Int)]
Error:(196, 26) not found: type TestListResultSink
    val resultSink = new TestListResultSink[String]
Error:(197, 30) not found: type TestListResultSink
    val lateResultSink = new TestListResultSink[(String, Int)]
Error:(242, 26) not found: type TestListResultSink
    val resultSink = new TestListResultSink[String]
Error:(243, 36) not found: type TestListResultSink
    val sideOutputResultSink = new TestListResultSink[String]
Error:(289, 26) not found: type TestListResultSink
    val resultSink = new TestListResultSink[String]
Error:(290, 36) not found: type TestListResultSink
    val sideOutputResultSink = new TestListResultSink[String]
apache-flink
3个回答
0
投票

如果我在GitHub.com上搜索TestListResultSink,我会发现它是here。这表明我在flink-tests模块中。你有没有在IntelliJ设置中包含它?


0
投票

我最终在IntelliJ中运行got org.apache.flink.examples.scala.wordcount.WordCount,但这并不容易。我尝试了很多东西,但我认为这是导致成功的道路:

  1. 检查了版本1.7分支(可能没关系,但我想确定我是在经过充分测试的代码集上)
  2. 通过mvn clean package -DskipTests在命令行上构建整个项目
  3. 在IntelliJ中做了一个无效的缓存/重启(我在IntelliJ中的Build Project期间一直遇到错误,直到我这样做)
  4. 构建项目(在IntelliJ中)
  5. org.apache.flink.examples.scala.wordcount.WordCountorg.apache.flink.streaming.scala.examples.wordcount.WordCount

FWIW,Flink二进制版本附带了一些示例的jar文件,这些示例可以针对集群运行而无需编译任何内容。这是一种更简单的方法来运行。详情是here


0
投票

尝试构建您的项目,然后运行wordcount示例!

mvn clean package -DskipTests

© www.soinside.com 2019 - 2024. All rights reserved.