在hadoop上运行时遇到“ java.lang.NoSuchMethodError:com.google.gson.GsonBuilder.registerTypeAdapterFactory”

时间:2018-08-30 21:16:59

标签: java gson

我正在为当前项目使用GSON库(V 2.8.2)。我在hadoop作业跟踪器上运行时遇到以下异常,而在YARN上运行良好。我在两种模式下都使用相同的uber jar。

我正在使用以下代码段创建gson实例

arresis

我在pom.xml中添加了以下依赖关系

arrests

例外:

    @Entity(tableName = "Category")
public class Cat extends AbstractItem<Cat, Cat.ViewHolder> {

    @PrimaryKey
    @NonNull
    @ColumnInfo(name = "CID")
    public String uid;

    public String getID() { return this.uid; }


    @ColumnInfo(name = "HeadID")
    public String iHeaduid;

    //...various getters and setters...

    public Cat() {}

    public Cat(String sNameP, int iCatLevelP, Cat oHeadCatP)
    {
        this.uid = UUID.randomUUID().toString();
        this.sName = sNameP;
        this.oSubCatList = new ArrayList<Cat>();
        this.iCatLevel = iCatLevelP;
        this.oHeadCat = oHeadCatP;
        if (this.oHeadCat != null) {
            this.sHeadName = oHeadCatP.sName;
            this.iHeaduid = oHeadCatP.uid;
        }
        else
            this.sHeadName = null;
    }

// Methods that implement AbstractItem - I already set them on ignore...

    @Ignore
    @Override
    public int getType() {
        return R.id.textViewCat;
    }

    @Ignore
    @Override
    public int getLayoutRes() {
        return R.layout.catrecyclerview_item;
    }

    @Ignore
    @Override
    public void bindView(ViewHolder holder) {
        super.bindView(holder);
    }

    protected static class ViewHolder extends RecyclerView.ViewHolder{

        protected TextView oTextView;
        public ViewHolder(View itemView) {
            super(itemView);
            oTextView = itemView.findViewById(R.id.textViewCat);
        }
    }
}

0 个答案:

没有答案