Home  >  Q&A  >  body text

java-web - Javabean 是否一定要实现Serializable接口?意义在哪?

如题,以及是否javabean中无论public还是private都序列化还是怎么样?希望有有人来讨论下,或者给出相关文档的链接。
小弟谢过

巴扎黑巴扎黑2716 days ago505

reply all(3)I'll reply

  • 阿神

    阿神2017-04-18 09:54:04

    1.serializeable is a marked interface with no methods to be implemented. The purpose of this interface is to tell Java that developers allow this class to be serialized.
    2. There is no specific test, but access modifiers such as public and private should not affect the serialization process.

    Another:

    I have previously written a blog article about Java serialization "Java Serialization Basics" which should be able to answer this question and introduce a simple way to call the Java serialization interface. The subject can test the access modifiers and Does serialization matter?

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-18 09:54:04

    Implements the Serializable是因为你需要使用JDK内置的序列化。
    以目前的技术来说是否实现Serializable接口已经不重要了,因为现在的序列化技术太多,都比JDK内置的要优秀,而且不需要实现Serializableinterface.
    EsotericSoftware/kryo
    msgpack
    FasterXML/jackson
    RuedigerMoeller/fast-serialization
    google/protobuf

    reply
    0
  • ringa_lee

    ringa_lee2017-04-18 09:54:04

    It does not have to be implemented, but some old systems still need it, such as some projects integrating backend and flex end, entities still need to be serialized

    reply
    0
  • Cancelreply