在IntelliJ Scala工作表中使用Apache Spark [英] Using Apache Spark in IntelliJ Scala Worksheet

查看:206
本文介绍了在IntelliJ Scala工作表中使用Apache Spark的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用最新的Scala-Plugin在IntelliJ 2016.3中使用Scala 2.10.5运行Apache Spark 1.6.3。该项目是一个maven项目。

I try to run Apache Spark 1.6.3 with Scala 2.10.5 in IntelliJ 2016.3 using the most recent Scala-Plugin. The project is a maven project.

如果我尝试使用以下方法创建一个新的SparkContext:

If I try to create a new SparkContext using :

val sparkConf = new SparkConf()
val sc = new SparkContext(sparkConf.setAppName("Spark-Scala-Demo").setMaster("local[*]"))

我得到

17/01/16 14:05:28 ERROR SparkContext: Error initializing SparkContext.
java.lang.ClassNotFoundException: org.apache.spark.rpc.netty.NettyRpcEnvFactory
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    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:175)
    at org.apache.spark.rpc.RpcEnv$.getRpcEnvFactory(RpcEnv.scala:41)

代码在IntelliJs scala控制台以及定义main方法的普通类中运行良好。

The code runs fine both in IntelliJs scala console as well as in a normal class defining a main-method.

那么什么在scala工作表中是不同的?

So what is different in a scala worksheet?

推荐答案

在工作表的开头尝试: import org。 apache.spark.rpc.netty

Try this at the beginning of the worksheet: import org.apache.spark.rpc.netty

这篇关于在IntelliJ Scala工作表中使用Apache Spark的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆