栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

flink的对象作为数据传输的要求

flink的对象作为数据传输的要求

@org.apache.flink.api.common.InvalidProgramException: This type (GenericType

对于java 的对象要求;属性必须是public 的修饰符,必须添加无参数构造方法

报错之前类对象
  public  class WorldValueDesc {
        private String word; // 属性设置私有 错误1
        private int cnt;   // 属性设置私有 错误1
        //没有添加无参数构造方法 错误1
        public WorldValueDesc(String word, int cnt) {
            this.word = word;
            this.cnt = cnt;
        }

        public void setWord(String word) {
            this.word = word;
        }

        public void setCnt(int cnt) {
            this.cnt = cnt;
        }

        public String getWord() {
            return word;
        }

        public int getCnt() {
            return cnt;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            WorldValueDesc that = (WorldValueDesc) o;
            return cnt == that.cnt &&
                    Objects.equals(word, that.word);
        }

        @Override
        public int hashCode() {
            return Objects.hash(word, cnt);
        }

        @Override
        public String toString() {
            return "WorldValueDesc{" +
                    "word='" + word + ''' +
                    ", cnt=" + cnt +
                    '}';
        }
    }
修改以后代码

public class WorldValueDesc {
public String word;
public int cnt;

public WorldValueDesc() {
}

public WorldValueDesc(String word, int cnt) {
    this.word = word;
    this.cnt = cnt;
}

public void setWord(String word) {
    this.word = word;
}

public void setCnt(int cnt) {
    this.cnt = cnt;
}

public String getWord() {
    return word;
}

public int getCnt() {
    return cnt;
}

@Override
public boolean equals(Object o) {
    if (this == o) return true;
    if (o == null || getClass() != o.getClass()) return false;
    WorldValueDesc that = (WorldValueDesc) o;
    return cnt == that.cnt &&
            Objects.equals(word, that.word);
}

@Override
public int hashCode() {
    return Objects.hash(word, cnt);
}

@Override
public String toString() {
    return "WorldValueDesc{" +
            "word='" + word + ''' +
            ", cnt=" + cnt +
            '}';
}

}

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/583093.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号