KafkaUtils.createDirectStream报错Cannot resolve symbol createDirectStream

KafkaUtils.createDirectStream报错Cannot resolve symbol createDirectStream_第1张图片

一开以为是自己导包导错了,但是对比了一下之前的程序发现并没有错,

import org.apache.spark.streaming.kafka.{HasOffsetRanges, KafkaUtils, OffsetRange}

后来又怀疑是不是自己搞错版本了,检查了好几次,在另外一台电脑上也是同样的pom啊

<dependency>
    <groupId>org.apache.sparkgroupId>
    <artifactId>spark-streaming_2.11artifactId>
    <version>1.6.0version>
dependency>
<dependency>
    <groupId>org.apache.sparkgroupId>
    <artifactId>spark-streaming-kafka_2.11artifactId>
    <version>1.6.0version>
dependency>

后来又猜是不是哪里有隐式转换啊,因为我把KafkaUtils.createDirectStream放到一个函数中就不报错了,奇怪了

KafkaUtils.createDirectStream[String, String, StringDecoder, StringDecoder](ssc,kafkaParams,topics)

搞了好久,最后是一个让我哭笑不得的原因导致的,topic的类型应该是Set,弄成Array了(话说Set确实更合理哈,自动去除重复的topic),说来也是气人,topic类型错了,IDEA就应该把错误标在topics上,标在createDirectStream误导人-_-||

KafkaUtils.createDirectStream报错Cannot resolve symbol createDirectStream_第2张图片

KafkaUtils.createDirectStream报错Cannot resolve symbol createDirectStream_第3张图片

 

转载于:https://www.cnblogs.com/144823836yj/p/11108357.html

你可能感兴趣的:(KafkaUtils.createDirectStream报错Cannot resolve symbol createDirectStream)