java.lang.NoSuchMethodException for init method in Scala case class

前端 未结 1 1209
[愿得一人]
[愿得一人] 2021-01-19 11:49

I am writing an Apache Flink streaming application that deserializes data (Avro format) read off a Kafka bus (more details on here). The data is being deserialized into a Sc

相关标签:
1条回答
  • 2021-01-19 12:34

    The Avro serializer or more specifically the SpecificData requires the target type to have a default constructor (constructor with no arguments). Otherwise Avro cannot instantiate an object of the target type.

    Try to add a default constructor via

    case class DeviceData(
        deviceId: String,
        sw_version: String,
        timestamp: String,
        reading: Double) {
      def this() = this("default", "default", "default", 0)
    } 
    
    0 讨论(0)
提交回复
热议问题