事情起因

https://github.com/chaoxxx/learn-flink-stream-api/blob/master/src/main/java/fun/cosmozhu/session16/main/StreamTest.java

这个repository被我clone下来后运行很顺利.

想复制到自己的另外一个工程里面,结果报错了

报错内容

22:45:50,226 INFO  org.apache.flink.api.java.typeutils.TypeExtractor  - class fun.cosmozhu.session16.pojo.ExchangeRateInfo is missing a default constructor so it cannot be used as a POJO type and must be processed as GenericType. 

Please read the Flink documentation on "Data Types & Serialization" for details of the effect on performance.
Exception in thread "main" org.apache.flink.api.common.InvalidProgramException: Type EnumTypeInfo<fun.cosmozhu.session16.pojo.CurrencyType> cannot be used as key. Contained UNSUPPORTED key types: EnumTypeInfo<fun.cosmozhu.session16.pojo.CurrencyType>. Look at the keyBy() documentation for the conditions a type has to satisfy in order to be eligible for a key.
    at org.apache.flink.streaming.api.datastream.KeyedStream.validateKeyType(KeyedStream.java:195)
    at org.apache.flink.streaming.api.datastream.KeyedStream.<init>(KeyedStream.java:162)
    at org.apache.flink.streaming.api.datastream.KeyedStream.<init>(KeyedStream.java:131)
    at org.apache.flink.streaming.api.datastream.KeyedStream.<init>(KeyedStream.java:118)
    at org.apache.flink.streaming.api.datastream.DataStream.keyBy(DataStream.java:296)
    at fun.cosmozhu.session16.main.StreamTest.main(StreamTest.java:57)

Process finished with exit code 1

调试技巧

到这里的时候,我基本上花了好几个小时都卡在这个问题上了.

最后是通过在原始的repository修改pom.xml中的flink版本从1.9.0改为1.11.2然后触发了上面的错误.

说明Flink 1.9.0-1.11.2对 pojo的格式要求已经发生了很大的变化.

然后注意,

application.properties终于logo的警告等级必须是INFO,不能是WARN,否则上面的提示信息你就看不到了.

22:45:50,226 INFO  org.apache.flink.api.java.typeutils.TypeExtractor  - class fun.cosmozhu.session16.pojo.ExchangeRateInfo is missing a default constructor so it cannot be used as a POJO type and must be processed as GenericType. 

application.properties示范:

log4j.rootLogger=INFO, consolelog4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p %-60c %x - %m%n

解决方案

package fun.cosmozhu.session16.pojo;
/*** 货币类型* @author cosmozhu* @mail zhuchao1103@gmail.com* @site http://www.cosmozhu.fun*/
public enum CurrencyType {USD,CNY,EUR,AUD}

改为:

package fun.cosmozhu.session16.pojo;
/*** 货币类型* @author cosmozhu* @mail zhuchao1103@gmail.com* @site http://www.cosmozhu.fun*/public enum CurrencyType {USD("美元"),CNY("人民币"),EUR("欧元"),AUD("澳元");private final String name;private CurrencyType(String name) {this.name = name;}public String getName() {return name;}
}

Type EnumTypeInfo<xxxxx> cannot be used as key. Contained UNSUPPORTED key types: EnumTypeInfo<xxxxx>相关推荐

  1. 庄懂的TA笔记(十三)<特效-混合模式:四种主要透明通道用法 AC,AB,AD,自定义混合>

    庄懂的TA笔记(十三)<特效-混合模式:四种主要透明通道用法 AC,AB,AD,自定义混合> 效果展示: 正文: 一.特效类大纲: 1.特效 · 透 2.特效 · 动 3.特效 · 映 二 ...

  2. Vue2 使用Volar 报错:<template v-for> key should be placed on the <template> tag

    问题 Vue2 项目开发,在 VS Code 上使用插件 Volar 来进行语法提示.语法检查. 对没有放在<template v-for>元素上的:key,会提示<template ...

  3. 关于react-router-dom 6.0.1的更新基本写法 解决Error: A <Route> is only ever to be used as the child of <Routes>

    文章目录 前言 一.先准备好要切换的组件 二.在 V5 版本则是这样使用 v5版本:`Router`直接包裹着`Route组件` 三.在V6版本则是这样使用 v6版本:`Route`需要先被`Rout ...

  4. 关于react-router-dom 6.0.1的基础写法 解决Error A <Route> is only ever to be used as the child of <Routes>

    在新建react项目中 使用react-router-dom 6.0.1版本难免会遇到以下报错 Error: A <Route> is only ever to be used as th ...

  5. 关于react-router-dom 6.0.1的基础写法 解决Error: A <Route> is only ever to be used as the child of <Routes>

    在新建react项目中 使用react-router-dom 6.0.1版本难免会遇到以下报错 Error: A <Route> is only ever to be used as th ...

  6. Error: A <Route> is only ever to be used as the child of <Routes> element, never rendereddirectly

    报错信息: Error: A < Route > is only ever to be used as the child of < Routes > element, nev ...

  7. Error: A <Route> is only ever to be used as the child of <Routes> element, never rendered directly.

    错误示例 index.jsx import React from "react"; import ReactDom from "react-dom";impor ...

  8. 【无标题】A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Pl

    版本问题的语法错误:可以选择npm i react-router-dom@5.2.0回到5版本,或者直接用6版本语法 A <Route> is only ever to be used a ...

  9. react-router-dom ^6.0.2使用过程中报错 Error: A <Route> is only ever to be used as the child of <Routes>

    因为react-router-dom更新的之后路由使用时做了一写改变 废话不多说,上代码 旧版本: import React from 'react' import ReactDOM from 're ...

最新文章

  1. 如何系统的学习单片机?
  2. jdb java_JDB - 介绍
  3. java redis设置过期时间_Redis的一些核心原理
  4. pearsonr() python_Python 来算算一线城市的二手房价格指数相关性
  5. 教学思路SQL之预备课程学习 建库、建表、建约束、关系、部分T-sql语句
  6. 洛谷 P2046 BZOJ 2007 海拔(NOI2010)
  7. 递归循环一个无限极数组_理解递归、尾调用优化和蹦床函数优化
  8. 将Spring源码转换为工程 + 导入Eclipse时缺失jar包
  9. Docker学习文档之三 其他相关-Docker常用命令
  10. VC Dimension -衡量模型与样本的复杂度
  11. CMP?MSP?1+1才能大于2
  12. 关于课题的一点思考(基于多生理信号的情绪识别)
  13. python的查找list的元素
  14. 腾讯即时通信 tim-sdk.js功能扩展
  15. 恐怖系列丨互联网幕后攻防:咳血的独角兽之血腥丛林中的无底线战争
  16. SQL Server无法连接到本地数据库
  17. 开启hadoop报错:localhost: Permission denied(publickey,gssapi-keyex,gssapi-with-mic,password).
  18. win10环境下配置Gradle
  19. 新品项目交付频繁 猿团开启APP快速开发新模式
  20. css为何不支持父元素选择器

热门文章

  1. 清除webkit浏览器css设置滚动条
  2. CentOS系统下docker的安装与卸载
  3. Swift - 从字典(或者Alamofire)直接创建Model文件的工具
  4. HTTP-post请求重定向后变成了GET请求
  5. pythonwhile循环实战教程_Python入门丨for循环和while循环
  6. 学习响应式BootStrap来写融职教育网站,Bootsrtap第十天你的收获
  7. springboot集成Swagger2接口文档
  8. 强网杯Web部分review
  9. ubuntu 系统分配固定 ip--
  10. Linux(CentOS)同步时间