问题
In spark-shell (which uses scala-repl), it seems impossible to make a (case) class which has the default constructor (i.e. no-argument constructor):
scala> case class Hello(i: Int) {
| def this() = this(0)
| }
defined class Hello
scala> classOf[Hello].getName
res1: String = Hello
scala> classOf[Hello].getConstructors()
res2: Array[java.lang.reflect.Constructor[_]] = Array(public Hello($iw), public Hello($iw,int))
This makes Jackson fail to deserialize something into this class, because there isn't a simple way to construct an instance of that class using reflection.
Is it possible to make a case class have a default constructor in spark shell?
来源:https://stackoverflow.com/questions/30592985/no-argument-constructor-in-spark-shell-scala-repl