我在火花流媒体应用程序中使用了一个java kafka函数
JavaInputDStream<Tuple2<String,String>> messages = KafkaUtils.createDirectStream(jssc,
String.class,
String.class,
StringDecoder.class,
StringDecoder.class,
Tuple2.class,
kafkaParams,
fromOffsets,
messageHandler);
记录输出与Tuple2的类型相同 由于
,上面给出了错误Tuple2.class
错误说:
The method createDirectStream(JavaStreamingContext, Class<K>, Class<V>, Class<KD>, Class<VD>, Class<R>, Map<String,String>, Map<TopicAndPartition,Long>, Function<MessageAndMetadata<K,V>,R>) in the type KafkaUtils is not applicable for the arguments (JavaStreamingContext, Class<String>, Class<String>, Class<StringDecoder>, Class<StringDecoder>, Class<Tuple2>, Map<String,String>, Map<TopicAndPartition,Long>, Function<MessageAndMetadata<String,String>,Tuple2<String,String>>)
如何为Tuple2使用class关键字&lt;字符串,字符串&GT;