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

The return type of function ‘main(WordCountToObject.java:28)‘ could not be determined automatically,

The return type of function ‘main(WordCountToObject.java:28)‘ could not be determined automatically,

java使用lamda表达式,出现类型无法自动识别到报一下异常

在这Exception in thread "main" org.apache.flink.api.common.functions.InvalidTypesException: The return type of function 'main(XXX.java:28)' could not be determined automatically, due to type erasure. You can give type information hints by using the returns(...) method on the result of the transformation call, or by letting your function implement the 'ResultTypeQueryable' interface.
	at org.apache.flink.api.dag.Transformation.getOutputType(Transformation.java:484)
	at org.apache.flink.streaming.api.datastream.DataStream.getType(DataStream.java:190)
	at org.apache.flink.streaming.api.datastream.DataStream.keyBy(DataStream.java:339)里插入代码片

解决方案;

  SingleOutputStreamOperator flatMap = streamSouce.flatMap((FlatMapFunction) (s, collector) -> {
            String[] str = s.split(",");
            for (String value : str) {
                collector.collect(new WorldValueDesc(value, 1));
            }
        }) // 显示指定匿名函数的返回类型
        .returns(TypeInformation.of(new TypeHint() {
            @Override
            public TypeInformation getTypeInfo() {
                return super.getTypeInfo();
            }
```java

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

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

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