Flink学习笔记
今天用scala开发Flink的job,测试出现下边的错误
GenericType<.Metric>) cannot be used as key.
例子是跟着官方SocketWindowWordCount的example的结构写的,example用了WordWithCount这样一个class,我也定义了一个类似的,但是奇怪的是一直报我定义的这个class不能作为key使用
最后再stackoverflow上找到了原因,https://stackoverflow.com/questions/33720947/apache-flink-streaming-type-mismatch-in-flatmap-function
主要是因为我用的scala api,但导入了java的org.apache.flink.streaming.api.environment.StreamExecutionEnvironment
改成导入import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment就好了
另外用scala开发Flink job,需要注意的是一定要import org.apache.flink.api.scala._,具体原因参考官网的解释 https://ci.apache.org/projects/flink/flink-docs-release-1.2/dev/linking_with_flink.html