使用时找不到齐柏林飞艇导入的类 [英] zeppelin imported classes not found when using

查看:24
本文介绍了使用时找不到齐柏林飞艇导入的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 zeppelin 上使用 spark 时出现奇怪的错误.我使用它们时找不到导入的类.代码示例是:

I get a weird error when using spark on zeppelin. The imported classes are not found when I use them. The code sample is :

%spark
import java.io.Serializable
import java.text.{ParseException, SimpleDateFormat}
import java.util.{Calendar, SimpleTimeZone}

class Pos(val pos: String) extends Serializable {

if (pos.length != 12) {
  throw new IllegalArgumentException(s"[${pos}] seems not a valid pos 
 string")
}

private val cstFormat = new SimpleDateFormat("yyyyMMddHHmm")
private val utcFormat = new SimpleDateFormat("yyyyMMddHHmm")
}

我收到以下错误:

import java.io.Serializable
import java.text.{ParseException, SimpleDateFormat}
import java.util.{Calendar, SimpleTimeZone}
<console>:17: error: not found: type SimpleDateFormat
     private val cstFormat = new SimpleDateFormat("yyyyMMddHHmm")
                                 ^
<console>:18: error: not found: type SimpleDateFormat
     private val utcFormat = new SimpleDateFormat("yyyyMMddHHmm")
                                 ^
<console>:25: error: not found: type ParseException
       case e: ParseException => throw newIllegalArgumentException(s"
               ^

有没有办法解决这个错误?zeppelin 版本是 0.7.3,spark 版本是 2.1提前致谢!

Is there any method to solve the error? The zeppelin version is 0.7.3 and spark version is 2.1 Thanks in advance!

推荐答案

在 Zeppelin 中,您必须在同一行中导入所有内容,以 ; 分隔.使其工作:

In Zeppelin, you have to import everything on the same line, separating with ; to make it work:

import java.io.Serializable; import java.text.{ParseException, SimpleDateFormat}; import java.util.{Calendar, SimpleTimeZone}; class Pos(val pos: String) extends Serializable {

if (pos.length != 12) {
  throw new IllegalArgumentException(s"[${pos}] seems not a valid pos 
 string")
}

private val cstFormat = new SimpleDateFormat("yyyyMMddHHmm")
private val utcFormat = new SimpleDateFormat("yyyyMMddHHmm")
}

这篇关于使用时找不到齐柏林飞艇导入的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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