解决java.lang.Exception: java.lang.NullPointerException
程序员文章站
2022-06-23 18:07:20
...
启动程序,控制台日志打印信息,发现错误信息:空指针异常
先用degger排除错误:
运行弹出这个界面
我们需要在OrderComparator类给序列化
OrderComparator.java
package com.study.groupingcomparator;
import org.apache.hadoop.io.WritableComparable;
import org.apache.hadoop.io.WritableComparator;
public class OrderComparator extends WritableComparator {
protected OrderComparator(){
super(OrderBean.class,true);
}
@Override
public int compare(WritableComparable a, WritableComparable b) {
OrderBean oa = (OrderBean) a;
OrderBean ob = (OrderBean) b;
return oa.getOrderId().compareTo(ob.getOrderId());
}
}
推荐阅读