原因:自己在pom文件中加入
<scope>provided</scope>
此标签表示编译环境可用,运行时则不可用,主要是在 打包时不将这些依赖打进来,因为服务器上有,以免包过大
解决方案:本地运行时注销掉<scope>provided</scope>,reimport maven projects
Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/spark/rdd/RDD
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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:125)
Caused by: java.lang.ClassNotFoundException: org.apache.spark.rdd.RDD
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)
… 6 more