讲真,下次打死我也不敢随便改serialVersionUID了
<h2 class="rich_media_title" id="activity-name">
讲真,下次打死我也不敢随便改serialVersionUID了
</h2>
<div id="meta_content" class="rich_media_meta_list">
<span class="rich_media_meta rich_media_meta_nickname" id="profileBt">
<a id="js_name">
码农沉思录 </a>
<div id="js_profile_qrcode" class="profile_container" style="display:none;">
<div class="profile_inner">
<strong class="profile_nickname">码农沉思录</strong>
<img class="profile_avatar" id="js_profile_qrcode_img" src="" alt="">
<p class="profile_meta">
<label class="profile_meta_label">微信号</label>
<span class="profile_meta_value">code-thinker</span>
</p>
<p class="profile_meta">
<label class="profile_meta_label">功能介绍</label>
<span class="profile_meta_value">笔者为国内某知名企业不知名码农,专注Java Web领域多年,有丰富的bug开发经验。</span>
</p>
</div>
<span class="profile_arrow_wrp" id="js_profile_arrow_wrp">
<i class="profile_arrow arrow_out"></i>
<i class="profile_arrow arrow_in"></i>
</span>
</div>
</span>
<em id="publish_time" class="rich_media_meta rich_media_meta_text">3天前</em>
</div>
<div class="rich_media_content " id="js_content">
<p style="font-family: -apple-system-font, BlinkMacSystemFont, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-align: right;" data-mpa-powered-by="yiban.io"><span style="color: rgba(0, 0, 0, 0.65);font-family: 'Monospaced Number', 'Chinese Quote', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;text-align: start;white-space: pre;letter-spacing: 1.4px;font-size: 12px;"></span></p><p style="text-align: center;"><img class="rich_pages " data-ratio="0.666" data-s="300,640" data-src="https://mmbiz.qpic.cn/mmbiz_jpg/XA3sPCPib1l5P34dAsQQPqibib8tyCUCMnwX6RXYICMHYibO8b56dpM8cuHhew6LceId2PJiaEbdsKDZ4Eggzur5UyA/640?wx_fmt=jpeg" data-type="jpeg" data-w="500" style="width: 500px !important; height: auto !important; visibility: visible !important;" _width="500px" src="" crossorigin="anonymous" data-fail="0"></p><section class="code-snippet__fix code-snippet__js"><pre class="code-snippet__js" data-lang="javascript"><code class="hljs"><span class="code-snippet_outer">来源:Java成长路</span></code><code class="hljs less"><span class="code-snippet_outer">链接:<span class="hljs-attribute"><span class="hljs-attribute">https</span></span>:<span class="code-snippet__comment"><span class="hljs-comment"><span class="hljs-comment">//www.jianshu.com/p/a4508a8f2420</span></span></span></span></code></pre></section><section style="font-size: 14px;letter-spacing: 1.4px;white-space: normal;line-height: 2em;margin: 1.5em 5px !important;">序列化是一种对象持久化的手段。普遍应用在网络传输、RMI等场景中。类通过实现 java.io.Serializable 接口以启用其序列化功能。</section><section style="font-size: 14px;letter-spacing: 1.4px;white-space: normal;line-height: 2em;margin: 1.5em 5px !important;">但是,还有一个知识点并未展开介绍,那就是关于serialVersionUID 。这个字段到底有什么用?如果不设置会怎么样?为什么《阿里巴巴Java开发手册》中有以下规定:</section><section style="font-size: 14px;letter-spacing: 1.4px;white-space: normal;line-height: 2em;margin: 1.5em 5px !important;"><img class="" data-ratio="0.1527777777777778" data-type="other" data-w="1080" data-src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4ZXozI7y0sxrnbthHA5eZ8qRHia8kegttJeOTzWuEAttacty5mBibQHvuw/640?wx_fmt=other" _width="677px" src="https://img2018.cnblogs.com/blog/1112483/201909/1112483-20190909143819446-485477025.png" crossorigin="anonymous" data-fail="0"></section><section style="font-size: 14px;letter-spacing: 1.4px;white-space: normal;line-height: 2em;margin: 1.5em 5px !important;"><strong style="color: rgb(191, 54, 12);">背景知识</strong></section><section style="font-size: 14px;letter-spacing: 1.4px;white-space: normal;line-height: 2em;margin: 1.5em 5px !important;">在展开本文的介绍之前,先来简单介绍一些和序列化有关的知识,</section><section style="font-size: 14px;letter-spacing: 1.4px;white-space: normal;line-height: 2em;margin: 1.5em 5px !important;"><strong style="color: rgb(191, 54, 12);">Serializable 和 Externalizable</strong></section><section style="font-size: 14px;letter-spacing: 1.4px;white-space: normal;line-height: 2em;margin: 1.5em 5px !important;">Java类通过实现 java.io.Serializable 接口以启用其序列化功能。<strong style="color: rgb(191, 54, 12);">未实现此接口的类将无法进行序列化或反序列化。</strong>可序列化类的所有子类型本身都是可序列化的。</section><p style="color: rgb(62, 62, 62);font-family: -apple-system-font, BlinkMacSystemFont, "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;font-size: 16px;white-space: normal;widows: 1;letter-spacing: 0.544px;background-color: rgb(255, 255, 255);text-align: center;"></p><section style="font-size: 14px;letter-spacing: 1.4px;white-space: normal;line-height: 2em;margin: 1.5em 5px !important;">如果读者看过Serializable的源码,就会发现,他只是一个空的接口,里面什么东西都没有。<strong style="color: rgb(191, 54, 12);">Serializable接口没有方法或字段,仅用于标识可序列化的语义。</strong>但是,如果一个类没有实现这个接口,想要被序列化的话,就会抛出java.io.NotSerializableException异常。</section><section style="font-size: 14px;letter-spacing: 1.4px;white-space: normal;line-height: 2em;margin: 1.5em 5px !important;">它是怎么保证只有实现了该接口的方法才能进行序列化与反序列化的呢?</section><section style="font-size: 14px;letter-spacing: 1.4px;white-space: normal;line-height: 2em;margin: 1.5em 5px !important;">原因是在执行序列化的过程中,会执行到以下代码:</section><section style="font-size: 14px;letter-spacing: 1.4px;white-space: normal;line-height: 2em;margin: 1.5em 5px !important;"><img class="" data-ratio="0.5575485799701047" data-type="other" data-w="669" data-src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4Zr7iaP8yEwHzfzaicHTBfibGaF3BZbCKiboDanJqzLzuKLxUTeBbcPI8klA/640?wx_fmt=other" _width="669px" src="https://img2018.cnblogs.com/blog/1112483/201909/1112483-20190909145454097-584363508.png
" crossorigin="anonymous" data-fail="0">
java.io.InvalidClassException: com.hollis.User1; local class incompatible: stream classdesc serialVersionUID = 1, local class serialVersionUID = 2


java.io.InvalidClassException: com.hollis.User1; local class incompatible: stream classdesc serialVersionUID = -2986778152837257883, local class serialVersionUID = 7961728318907695402
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = xxxxL;






<div class="read-more__area" id="js_more_read_area" style="display:none;">
</div>
<div class="reward_area tc reward_area_primary" id="js_preview_reward_author" style="display:none;">
</div>
原文地址:https://mp.weixin.qq.com/s/HP4P4IcD8oTEovBUSq54pA
讲真,下次打死我也不敢随便改serialVersionUID了的更多相关文章
- 讲真,MySQL索引优化看这篇文章就够了
本文主要讨论MySQL索引的部分知识.将会从MySQL索引基础.索引优化实战和数据库索引背后的数据结构三部分相关内容,下面一一展开. 一.MySQL——索引基础 首先,我们将从索引基础开始介绍一下什么 ...
- 讲真,这两个IDE插件,可以让你写出质量杠杠的代码
昨晚躺在床上看<拯救大兵瑞恩>的时候,不由得感叹道:"斯皮尔伯格的电影质量真高,片头真实地还原了二战的残酷性."看完后,我的精神异常的亢奋,就想写篇文章来帮助大家提高一 ...
- 讲真,你是因为什么才买华为P20系列手机!
华为P20系列手机上市两个半月发货600万台!600万台?!看到这个亮瞎我钛合金狗眼的数据,且容我掰着手指脚趾算一下,算了,还是容我毫不夸张的感叹一句吧:华为做手机不用桨,不需风,全靠“浪”……. 两 ...
- 讲真,这两款idea插件,能治愈你英语不好的病
时不时就有小伙伴问我,"二哥,能推荐一款 IDE 吗?"你看这话问的,现在搞 Java 的不都在用 Intellij IDEA 吗,还用得着推荐(我已经和 Eclipse 分手了) ...
- ARCH-LINUX 折(安)腾(装)记
2016-08-09 前几天装的manjaro一直卡住,今天想换archlinux.... 先联个网.....wifi-menu 写入U盘 tuna 下载了ISO UltraISO 写进U盘,结果出问 ...
- PE文件格式详解,第一讲,DOS头文件格式
PE文件格式详解,第一讲,DOS头文件格式 今天讲解PE文件格式的DOS头文件格式 首先我们要理解,什么是文件格式,我们常说的EXE可执行程序,就是一个文件格式,那么我们要了解它里面到底存了什么内容 ...
- React Native (0.57)开发环境搭建(注意:Node不要随便更新到最新版,更新完后莫名其妙的问题一大堆)
搭建开发环境 一.安装依赖 必须安装的依赖有:Node.Watchman 和 React Native 命令行工具以及 Xcode. 1.首先安装 Homebrew 2.安装 Node, Watchm ...
- Mac 上真机调试cocos2d-x-3.16的test程序
文章比较长,一个算是新手又不是新手的程序员的解决过程. 一 xcode中打开项目 首先,下载完成cocos2d-x-3.16之后,解压,然后在根目录build目录下双击cocos2d_tests.xc ...
- 清北学堂2018DP&图论精讲班 DP部分学习笔记
Day 1 上午 讲的挺基础的--不过还是有些地方不太明白 例1 给定一个数n,求将n划分成若干个正整数的方案数. 例2 数字三角形 例7 最长不下降子序列 以上太过于基础,不做深入讨论 例3 给定一 ...
随机推荐
- Css中的!important
转载自:https://www.cnblogs.com/cang12138/p/7326280.html !important为开发者提供了一个增加样式权重的方法,比直接在元素的 style 属性中设 ...
- js利用递归与promise 按顺序请求数据
问题:项目中有一个需求,一个tabBar下面如果没有内容就不让该tabBar显示,当然至于有没有内容,需要我们通过请求的来判断,但是由于请求是异步的,如何让请求按照tabBar的顺序进行? 方案:我们 ...
- vue,一路走来(17)--底部tabbar切换
<router-link></router-link>存在router-link-active属性,那么底部tabbar切换就简单多了.不会再出现刷新回到第一个的bug. &l ...
- MySQL06-- mysql索引
目录 一.索引介绍 1.什么是索引 2.索引类型介绍 3.索引管理 5.索引操作 6.前缀索引 7.联合索引 8.创建索引总结: 一.索引介绍 1.什么是索引 1)索引就好比一本书的目录,它能让你更快 ...
- spark 计算结果写入mysql 案例及常见问题解决
package com.jxd import org.apache.spark.SparkContextimport org.apache.spark.SparkConfimport java.sql ...
- 厉害了!新AI人工智能研究令人大开眼界
AI人工智能有很多方法可以操纵照片,让您看起来更好看,消除红眼或镜头眩光等等.但到目前为止,眨眼已经证明了一个顽强的快照对手. 这远远不是智能“绘画中”的唯一例子,因为当一个程序用它认为属于的地方填充 ...
- python 关于每个项目的解释器
在写程序的时候发现了一个问题,就是我原来import的第三方包,在新建的项目里仍然报错,还需要重新下载一次 发现:原来每建一个新项目,python会默认生成另一个新的解释器和相关虚拟环境,包括第三方包 ...
- springboot redis操作
redis五大类型用法 Redis五大类型:字符串(String).哈希/散列/字典(Hash).列表(List).集合(Set).有序集合(sorted set)五种Controller:@Reso ...
- C#高级编程笔记 (1至6章节)数组,类/方法/泛型
2.3变量 var 类型推断 type 类的分类 如:type nametype = name.GetType(); //取变量name的类型 const 常量 const int painame ...
- Yii2 kineditor
用 kineditor实现异步 <table cellspadding=5 width=400> <tr height='150'> <td valign="t ...