标题Spark Mavem项目在本地测试报错 : Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/spark/SparkConf

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/spark/SparkConf
	at StreamingT$.main(StreamingT.scala:8)
	at StreamingT.main(StreamingT.scala)
Caused by: java.lang.ClassNotFoundException: org.apache.spark.SparkConf
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 2 more

  原因
NoClassDefFoundError表示在运行时找不到类

   <!--运行依赖-->
    <dependencies>
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-core_2.11</artifactId>
            <version>2.3.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

<scope>provided</scope>导致在编译时忽略了这个依赖! 把这行注释掉即可!如果打包时不需要将这个依赖打进去 , 则需要开启!
测试

    <!--运行依赖-->
    <dependencies>
        <dependency>
            <groupId>org.apache.spark</groupId>
            <artifactId>spark-core_2.11</artifactId>
            <version>2.3.0</version>
            <!--<scope>provided</scope>-->
        </dependency>
    </dependencies>

  

 

posted @ 2020-02-23 20:10  Xiaohu_BigData  阅读(3588)  评论(0编辑  收藏  举报