序列化

作者: Kinvo | 来源:发表于2019-03-29 09:33 被阅读0次

    父类序列化不了可以改成组合的方式,把原来的父类当成一个成员,代码如下:

    class SOAPAScalaLogger() extends Serializable {
      @transient
      var logger: SOAPALogger = null
      var moduleName: String = null
    
      def setModuleName(name: String): Unit = {
        moduleName = name
      }
    
      private def writeObject(out: ObjectOutputStream): Unit = {
        out.defaultWriteObject()
        out.writeObject(SOAPALogger.getAppID())
      }
    
      private def readObject(in: ObjectInputStream): Unit = {
        in.defaultReadObject()
        val appID = in.readObject().asInstanceOf[String]
        SOAPALogger.setAppID(appID)
        logger = SOAPALogManager.getLogger(moduleName, new SOAPACategoryFactory).asInstanceOf[SOAPALogger];
      }
    }
    

    java的序列化
    scala的序列化
    java的zipfile序列化
    no valid constructor错误

    相关文章

      网友评论

          本文标题:序列化

          本文链接:https://www.haomeiwen.com/subject/ekykbqtx.html