Spark java+scala项目打包(jar)

1.法1:maven打包
pom.xml文件


            
                maven-assembly-plugin
                
                    false
                    
                        jar-with-dependencies
                    
                    
                        
                                                  ch.kmeans2.SparkStreamingKMeansKafkaExample
                        
                    
                
                
                    
                        make-assembly
                        package
                        
                            assembly
                        
                    
                
            
            
                org.scala-tools
                maven-scala-plugin
                2.15.2
                
                    
                        scala-compile-first
                        
                            compile
                        
                        
                            
                                **/*.scala
                            
                        
                    
                    
                        scala-test-compile
                        
                            testCompile
                        
                    
                
            
        

然后使用mvn clean package命令进行打包,如果提交到集群运行遇到Exception in thread "main" java.lang.AbstractMethodError,考虑项目中spark的版本和集群运行版本是否一直
2.法2:idea打包
Project->Module Setting->Artifacts
图片.png
然后Build Artifact输出jar包

你可能感兴趣的:(spark)