Spark Streaming:updateStateByKey报错 is not applicable for the arguments...

ones.updateStateByKey(new Function2<List<Integer>, Optional<Integer>, Optional<Integer>>() {
            @Override
            public Optional<Integer> call(List<Integer> arg0, Optional<Integer> arg1) throws Exception {
                // TODO Auto-generated method stub
                return null;
            }
        });

对JavaPairDStream<String, Integer> ones使用updateStateByKey报错:

The method updateStateByKey(Function2<List<Integer>,Optional<S>,Optional<S>>) in the type JavaPairDStream<String,Integer> is not applicable for the arguments (new Function2<List<Integer>,Optional<Integer>,Optional<Integer>>(){})

解决办法:很可能是Optional导包导错了,要导com.google.common.base.Optional

原文地址:https://www.cnblogs.com/144823836yj/p/11052194.html