1. 复制官方wordcount demo报错,MultipleParameterTool 依赖依赖找不到?
官方地址:https://github.com/apache/flink/blob/master/flink-examples/flink-examples-batch/src/main/java/org/apache/flink/examples/java/wordcount/WordCount.java
final ParameterTool params = ParameterTool.fromArgs(args); //老版本
final MultipleParameterTool params = MultipleParameterTool.fromArgs(args); // FlinkVersion1.9.2引入
所以,如果想用MultipleParameterTool 的话,就在创建quickstart小demo的时候,版本改成如下
curl https://flink.apache.org/q/quickstart.sh | bash -s 1.9.2 //或者更高
2.java.lang.NoClassDefFoundError:org/apache/flink/api/common/ExecutionConfig$GlobalJobParameters
java.lang.NoClassDefFoundError: org/apache/flink/api/common/ExecutionConfig$GlobalJobParameters
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
at java.lang.Class.getMethod0(Class.java:3018)
at java.lang.Class.getMethod(Class.java:1784)
at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: org.apache.flink.api.common.ExecutionConfig$GlobalJobParameters
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 7 more
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main"
Process finished with exit code 1
官方解释:
解决办法:
3.java.lang.NoClassDefFoundError: org/apache/flink/api/common/ExecutionConfig$GlobalJobParameters
出现这类问题,因为我一直在用的是jdk11,而这个项目在pom文件里面看到的是jdk1.8,基本上idea上的配置和Flink需要的环境不匹配,也就是没有配置好jdk。
所以修改完毕之后,WC程序跑起来了。