在Spark shell中,SparkContext已经创建,变量名为sc。在启动spark-shell 时可以配置--master 参数,或--jars
$ ./bin/spark-shell --master local[4]
将code.jar 添加到classpath
$ ./bin/spark-shell --master local[4] --jars code.jar
使用maven坐标添加依赖
$ ./bin/spark-shell --master local[4] --packages "org.example:example:0.1"