Spark-用IDEA写wordcount程序时(scala语言),上传到集群中运行出错:java.lang.ClassNotFoundException: WordCount

1.出错信息:

java.lang.ClassNotFoundException: WordCount
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Class.java:348)
        at org.apache.spark.util.Utils$.classForName(Utils.scala:229)
        at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:695)
        at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:187)
        at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:212)
        at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:126)
        at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
出错信息

2.原因:
是因为在pom文件添加依赖时,未添加以下内容,导致打包出错,将以下内容添加后再打包,上传到集群运行时,则没有问题:

    
        
            
                net.alchim31.maven
                scala-maven-plugin
                3.2.2
                
                    
                        compile-scala
                        compile
                        
                            add-source
                            compile
                        
                    
                    
                        test-compile-scala
                        test-compile
                        
                            add-source
                            testCompile
                        
                    
                
                
                    2.11.4
                
            
        

    

3.添加之后,问题解决

你可能感兴趣的:(Spark-用IDEA写wordcount程序时(scala语言),上传到集群中运行出错:java.lang.ClassNotFoundException: WordCount)