flink keyBy报错

flink 执行keyBy操作出现异常情况:

Exception in thread "main" org.apache.flink.api.common.InvalidProgramException: This type (GenericType<com.hmh.entity.SensorEntity>) 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.hmh.action.OperationActionTest1.main(OperationActionTest1.java:38)

 

javabean

@Data
@AllArgsConstructor
public class SensorEntity {

private String id ;
private long time;
private double tmpeature;

}

 

解决:新增无参数的构造函数

@Data
@AllArgsConstructor
@NoArgsConstructor
public class SensorEntity {

private String id ;
private long time;
private double tmpeature;

}

 

上一篇:flink支持哪些时间语义?


下一篇:Flink实战(七) - Time & Windows编程