当前位置:网站首页>The IDEA to automatically generate the serialVersionUID
The IDEA to automatically generate the serialVersionUID
2022-08-10 03:32:00 【struggling newbie】
Serialization and Deserialization
Java is an object-oriented language. To interact with other languages (such as HTTP communication with front-end js), it is necessary to convert objects into a common format such as json (the front-end obviously does not recognize Java objects), from objects to json charactersThe conversion of strings is the process of serialization, and conversely, the conversion from json strings to Java objects is the process of deserialization.
What is serialVersionUID
The deserialization process requires generating a Java object from a json string.
There will be a problem at this time. It is necessary to verify whether the input json string is serialized from the current Request class. SerialVersionUID is used for this.When the serialVersionUID during serialization is inconsistent with the serialVersionUID during deserialization, an InvalidCalssException will be thrown.
The specific serialization process is as follows: During the serialization operation, the system will write the serialVersionUID of the current class into the serialized file. When deserializing, the system will detect the serialVersionUID in the file to determine whether it matches the serialization.The serialVersionUID of the current class is consistent. If it is consistent, it means that the version of the serialized class is the same as the current class version, and the deserialization can be successful, otherwise it will fail.
How to generate
First we will implement the interface, so how to automatically generate serialVersionUID.
Set the way to automatically generate serialVersionUID as shown below
After checking as shown in the picture, select the class name, and then press alt+enter to display the options shown below
Once selected, it will generate
边栏推荐
猜你喜欢
随机推荐
第二十一章 源代码文件 REST API 参考(三)
网页挖矿溯源?浏览器浏览历史查看工具Browsinghistoryview
《GB39707-2020》PDF下载
ECCV 2022 Oral | CCPL: 一种通用的关联性保留损失函数实现通用风格迁移
liunx PS1 settings
SQLserver加个判断
【QT】QT项目:自制Wireshark
2022强网杯 Quals Reverse 部分writeup
what is a microcontroller or mcu
liunx PS1 设置
【图像分类】2022-CycleMLP ICLR
[Red Team] ATT&CK - Self-starting - Self-starting mechanism using LSA authentication package
量化交易策略介绍及应用市值中性化选股
Algorithm and voice dialogue direction interview question bank
Introduction and application of quantitative trading strategies
通关剑指 Offer——剑指 Offer II 012. 左右两边子数组的和相等
Research on IC enterprises
小菜鸟河北联通上岗培训随笔
Robust Real-time LiDAR-inertial Initialization(实时鲁棒的LiDAR惯性初始化)论文学习
如何编写一份优质的测试用例?