如何注册java。util。apacheflink中的列表类型
是否可以将Environment#registerType
用于java.util.List
或其他集合类型?
如果我这样做:
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.getConfig().disableGenericTypes();
env.registerType(List.class);
我仍然得到Generic types have been disabled in the ExecutionConfig and type java.util.List is treated as a generic type.
我确实想做的是,但由于类型擦除,在Java中不可能做到的是:
StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
env.getConfig().disableGenericTypes();
env.registerType(List<MyClass>.class);
不幸的是,我在文档中或使用搜索引擎时没有找到解决方案
# 1 楼答案
像这样实现
List<T>
怎么样然后,您可以使用specifict
MyClass
注册类型MyClassList