类型信息未定义

TypeInformation not defined

object EventConsumer {

  def main(args: Array[String]): Unit = {
    val env  = ExecutionEnvironment.getExecutionEnvironment

    val data1 =   env.readTextFile("file:////some_events.txt");
    // Define the data source
    data1 .map (new myMapFunction)
  }

  class myMapFunction extends MapFunction[String,Unit]
  {
    override def map(in: String): Unit = {
      println(in)
    }
  }
}

纠结这个编译错误好久了,求助。

Error:(27, 15) could not find implicit value for evidence parameter of type org.apache.flink.api.common.typeinfo.TypeInformation[String]
      flatMap { _.split("\n")}.filter(_.nonEmpty).map (new myMapFunction)

Error:(24, 15) not enough arguments for method map: (implicit evidence: org.apache.flink.api.common.typeinfo.TypeInformation[Unit], implicit evidence: scala.reflect.ClassTag[Unit])org.apache.flink.api.scala.DataSet[Unit].
Unspecified value parameters evidence, evidence.
    data1.map (new myMapFunction)
              ^
              ^

使用 Flink 的 Scala 数据集时 API 需要将以下导入添加到您的代码中:import org.apache.flink.api.scala._.

使用 Flink 的 Scala DataStream 时 API 你必须导入 import org.apache.flink.streaming.api.scala._.

原因是包对象包含生成缺少的 TypeInformation 个实例的函数。