StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.setStreamTimeCharacteristic(TimeCharacteristic.EventTime);
dataStream.filter(data -> "test".equals(data.getTag())).keyBy("userId");
......
执行报错:
Exception in thread "main" org.apache.flink.api.common.InvalidProgramException: This type (GenericType<com.zixi.User>) cannot be used as key.
at org.apache.flink.api.common.operators.Keys$ExpressionKeys.<init>(Keys.java:330)
at org.apache.flink.streaming.api.datastream.DataStream.keyBy(DataStream.java:340)
at com.zixi.main(UserTest.java:58)
解决办法:
1.提供默认无参构造函数
2.字段名必须声明为public
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。