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

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

问题描述

在齐柏林飞艇上使用火花时出现奇怪的错误.当我使用导入的类时,找不到它们.代码示例是:

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"
               ^

有什么方法可以解决该错误? 齐柏林飞艇版本为0.7.3,星火版本为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天全站免登陆