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;
}