org.apache.flink.api.common.functions.InvalidTypesException

本文探讨了在使用Flink时遇到的`org.apache.flink.api.common.functions.InvalidTypesException`问题,该问题源于lambda表达式的类型信息在某些编译器下无法被正确提取。Flink依赖于类型继承来获取信息,但lambda的匿名特性导致困难。解决方案是根据官方文档,当使用如flatmap等算子时,需要手动指定返回类型,例如通过调用`Types`进行类型声明。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

org.apache.flink.api.common.functions.InvalidTypesException: The return type of function 'main(Main1.java:15)' 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.streaming.api.transformations.StreamTransformation.getOutputType(StreamTransformation.java:386)
	at org.apache.flink.streaming.api.datastream.DataStream.getType(DataStream.java:175)
	at org.apache.flink.streaming.api.datastream.DataStream.filter(DataStream.java:672)
	at main.Main1.main(Main1.java:19)
Caused by: org.apache.flink.api.common.functions.InvalidTypesException: The generic type parameters of 'Collector' are missing. 
It seems that your compiler has not stored them into the .class file. 
Currently, only the Eclipse JDT compiler preserves the type information necessary to use the lambdas feature 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值