Flink中scala提示错误——could not find implicit value for evidence parameter of type org.apa

17 篇文章 0 订阅

Flink第一个简单的demo ,wordCount

该问题参考引用如下:

https://blog.csdn.net/dax1n/article/details/70211035


自身代码中问题:

package cetc.flink

import org.apache.flink.api.scala.ExecutionEnvironment

object FlinKMain {

  def main(args: Array[String]): Unit = {
    // 1.设置运行环境
    val env = ExecutionEnvironment.getExecutionEnvironment

    //2.创造测试数据
    val text = env.fromElements("To be, or not to be,that is the question")

    //3.进行wordcount运算
    val counts = text.flatMap(_.toLowerCase.split("\\W+"))
      .map((_, 1)).groupBy(0).sum(1)
    //4.打印测试结构
    counts.print()
    
  }
  
}

运行时候出错如下:

Error:(13, 32) could not find implicit value for evidence parameter of type org.apache.flink.api.common.typeinfo.TypeInformation[String]
    val text = env.fromElements("To be, or not to be,that is the question")
Error:(13, 32) not enough arguments for method fromElements: (implicit evidence$14: scala.reflect.ClassTag[String], implicit evidence$15: org.apache.flink.api.common.typeinfo.TypeInformation[String])org.apache.flink.api.scala.DataSet[String].
Unspecified value parameter evidence$15.
    val text = env.fromElements("To be, or not to be,that is the question")

解决问题:

这是因为在当前环境之下找到不到scala的包,引入如下声明即可

import org.apache.flink.api.scala._

产生这个问题的原因(官网说明):

1:A frequent reason if that the code that generates the TypeInformation has not been imported. Make sure to import the entire flink.api.scala package.

2:Another common cause are generic methods, which can be fixed as described in the following section.

我碰到的是问题1的情况。

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值