简体   繁体   中英

It is required to implement Serializable interface when declaring a class?

While coding with Spring, I always see the most developers implements the Serializable interface. So, I want the reason why to work with this implementation in all decalaration of classes. Thank you !

Serialization is not a Spring-specific feature. You use serialization to transfer objects over the wire or store in the filesystem.

But according to effective java , serialization is dangerous and should not be used at all costs due to security holes. Another disadvantage to serialization is when you release a new version of your class to the public you'll need to make sure to support the old deserialized class.

Moral of the story: Don't ever use serialization in your code. For more info read chapter 12 of effective java book.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM