我在 IDEA 環境中調試 Kafka+Flink 自己編寫的例子時
代碼編譯都是通過的,但是進行Debug調試時,出現如下異常;
java.lang.NoClassDefFoundError: org/apache/flink/streaming/util/serialization/DeserializationSchema 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.streaming.util.serialization.DeserializationSchema at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 7 more Disconnected from the target VM, address: '127.0.0.1:55548', transport: 'socket' Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" Process finished with exit code 1
該配置maven的,也配置了,該加的jar也加了。
死活就是無法DEBUG,啟動報錯,直接就不能啟;
找了很久原因,最終找到了原因:
在 Run/ Edit Configurations 中勾選 Include dependencies with “Provided” scope,保存之后再運行就好了。
搞定。