一.IDEA打包过程:
1.新建一个测试程序:
package com.sparkcore import org.apache.spark.{SparkConf, SparkContext} import scala.math.random object Test_jar { def main(args: Array[String]): Unit = { val spark = new SparkContext(new SparkConf().setAppName("SparkPi02")) val slices = if (args.length > 0) args(0).toInt else 2 val n = math.min(100000L * slices, Int.MaxValue).toInt val count = spark.parallelize(1 until n, slices).map { i => val x = random * 2 - 1 val y = random * 2 - 1 if (x * x + y * y < 1) 1 else 0 }.reduce(_ + _) println("Pi is roughly" + 4.0 * count / n) spark.stop() } }
2.打包:
file--Project Structure---Artifacts--JAR---From modules with dependencies
下面需要选择要打包的程序: