讲真,下次打死我也不敢随便改serialVersionUID了

<div id="img-content">
                
                <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 href="javascript:void(0);" 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">smartyuge</span>
                              </p>

                              <p class="profile_meta">
                              <label class="profile_meta_label">功能介绍</label>
                              <span class="profile_meta_value">分享Python、Java、前端、大数据、机器学习、人工智能等技术,关注码农技术提升•职场突围•思维跃迁,15万+程序员的成长充电站。</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">今天</em>

                </div>

                

                

                


                
                
                                <a class="original_area_primary original_primary_overflow" id="copyright_info" href="##" style="visibility: visible;">
                    <span class="tips_global_primary">文章转载自公众号</span>
                    <span class="radius_avatar">
                                            <img class="avatar" src="http://wx.qlogo.cn/mmhead/Q3auHgzwzM7xaK6JmYge7lMoB3FpZpGOVU9TuoeZ5yP3YsOfyAmSVw/0" alt="Hollis">
                                          </span>
                    <span class="original_primary_nickname rich_media_meta_link js_nickname">Hollis</span>
                                        <span class="tips_global_primary" id="js_comma" style="visibility: visible;">,</span>
                    <span class="original_primary_author_wrp tips_global_primary" id="js_author" style="margin-left: 0px;">
                      作者                                            Hollis
                                          </span>
                                    </a>
                                
                
                
                
                                                
                                                                
                                
                
                <div class="rich_media_content " id="js_content">
                    

                    

                    
                    
                    <p style="font-family: -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(62, 62, 62);font-size: 15px;background-color: rgb(255, 255, 255);word-spacing: 2px;text-align: center;" data-mpa-powered-by="yiban.io"><span style="letter-spacing: 0.544px;font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;caret-color: rgb(51, 51, 51);widows: 1;font-size: 14px;color: rgb(136, 136, 136);">击上方“</span><span style="letter-spacing: 0.544px;font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;caret-color: rgb(62, 62, 62);color: rgb(255, 76, 65);"><strong style="letter-spacing: 0.544px;caret-color: rgb(51, 51, 51);widows: 1;"><span style="font-size: 14px;">码农突围</span></strong></span><span style="letter-spacing: 0.544px;font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;caret-color: rgb(51, 51, 51);widows: 1;font-size: 14px;color: rgb(136, 136, 136);">”,马上关注,每天早上</span><span style="letter-spacing: 0.544px;font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;caret-color: rgb(62, 62, 62);color: rgb(255, 76, 65);"><strong style="letter-spacing: 0.544px;caret-color: rgb(51, 51, 51);widows: 1;"><span style="font-size: 14px;">8:50</span></strong></span><span style="letter-spacing: 0.544px;font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;caret-color: rgb(51, 51, 51);widows: 1;font-size: 14px;color: rgb(136, 136, 136);">准时推送</span></p><section class="" powered-by="xiumi.us" style="letter-spacing: 0.544px;white-space: normal;color: rgb(62, 62, 62);background-color: rgb(255, 255, 255);font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;word-spacing: 2px;text-align: right;font-size: 14px;caret-color: rgb(51, 51, 51);"><section><section style="text-align: center;"><section style="margin-right: 16px;margin-left: 16px;font-size: 15px;font-variant-numeric: normal;font-variant-east-asian: normal;letter-spacing: 0.544px;line-height: 27.2px;widows: 1;"><span style="color: rgb(136, 136, 136);font-size: 14px;">真爱,请置顶或星标</span></section></section></section></section><p style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(0, 0, 0);font-size: 16px;text-align: center;"><span style="letter-spacing: 0.544px;font-family: Optima-Regular, PingFangTC-light;widows: 1;color: rgb(127, 127, 127);font-size: 14px;"><img class="" data-croporisrc="https://mmbiz.qlogo.cn/mmbiz_jpg/rtJ5LhxxzwnDtIWYicQCRficDsiahEa9HZAQgt662MZ4eOLp9ub2AhibQukLketsPPTpLnXQnzJT2GYFaibo0mUHnmg/0" data-cropx1="0" data-cropx2="960" data-cropy1="38.46689895470384" data-cropy2="583.6933797909409" data-ratio="0.5677083333333334" data-src="https://mmbiz.qpic.cn/mmbiz_jpg/rtJ5LhxxzwnDtIWYicQCRficDsiahEa9HZAZCEib6HicmCLe0W4jFlY6BAmTVicBJRMGpP21ADph6dVmAEF3lhNJsGPQ/640?wx_fmt=jpeg" data-type="jpeg" data-w="960" style="width: 574px !important; height: auto !important; visibility: visible !important;" _width="574px" src="https://mmbiz.qpic.cn/mmbiz_jpg/rtJ5LhxxzwnDtIWYicQCRficDsiahEa9HZAZCEib6HicmCLe0W4jFlY6BAmTVicBJRMGpP21ADph6dVmAEF3lhNJsGPQ/640?wx_fmt=jpeg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" crossorigin="anonymous" data-fail="0"></span></p><p style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;color: rgb(0, 0, 0);font-size: 16px;text-align: center;"><span style="letter-spacing: 0.544px;font-family: Optima-Regular, PingFangTC-light;widows: 1;color: rgb(127, 127, 127);font-size: 14px;"><span style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;font-size: 14px;text-align: left;white-space: pre;background-color: rgba(0, 0, 0, 0.03);">来源:https:</span><span class="code-snippet__comment" style="font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;font-size: 14px;text-align: left;white-space: pre;background-color: rgba(0, 0, 0, 0.03);">//www.jianshu.com/p/a4508a8f2420</span></span></p><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">序列化是一种对象持久化的手段。普遍应用在网络传输、RMI等场景中。类通过实现 java.io.Serializable 接口以启用其序列化功能。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">但是,还有一个知识点并未展开介绍,那就是关于serialVersionUID 。这个字段到底有什么用?如果不设置会怎么样?为什么《阿里巴巴Java开发手册》中有以下规定:</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;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" style="visibility: visible !important; width: 677px !important; height: auto !important;" _width="677px" src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4ZXozI7y0sxrnbthHA5eZ8qRHia8kegttJeOTzWuEAttacty5mBibQHvuw/640?wx_fmt=other&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" crossorigin="anonymous" data-fail="0"></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><strong style="color: rgb(191, 54, 12);">背景知识</strong></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">在展开本文的介绍之前,先来简单介绍一些和序列化有关的知识,</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><strong style="color: rgb(191, 54, 12);">Serializable 和 Externalizable</strong></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">Java类通过实现 java.io.Serializable 接口以启用其序列化功能。<strong style="color: rgb(191, 54, 12);">未实现此接口的类将无法进行序列化或反序列化。</strong>可序列化类的所有子类型本身都是可序列化的。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;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-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">它是怎么保证只有实现了该接口的方法才能进行序列化与反序列化的呢?</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">原因是在执行序列化的过程中,会执行到以下代码:</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;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" style="visibility: visible !important; width: 669px !important; height: auto !important;" _width="669px" src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4Zr7iaP8yEwHzfzaicHTBfibGaF3BZbCKiboDanJqzLzuKLxUTeBbcPI8klA/640?wx_fmt=other&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" crossorigin="anonymous" data-fail="0"></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">在进行序列化操作时,会判断要被序列化的类是否是Enum、Array和Serializable类型,如果都不是则直接抛出NotSerializableException。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">Java中还提供了Externalizable接口,也可以实现它来提供序列化能力。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">Externalizable继承自Serializable,该接口中定义了两个抽象方法:writeExternal()与readExternal()。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">当使用Externalizable接口来进行序列化与反序列化的时候需要开发人员重写writeExternal()与readExternal()方法。否则所有变量的值都会变成默认值。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><strong style="color: rgb(191, 54, 12);">transient</strong></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">transient 关键字的作用是控制变量的序列化,在变量声明前加上该关键字,可以阻止该变量被序列化到文件中,在被反序列化后,transient 变量的值被设为初始值,如 int 型的是 0,对象型的是 null。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><strong style="color: rgb(191, 54, 12);">自定义序列化策略</strong></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">在序列化过程中,如果被序列化的类中定义了writeObject 和 readObject 方法,虚拟机会试图调用对象类里的 writeObject 和 readObject 方法,进行用户自定义的序列化和反序列化。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">如果没有这样的方法,则默认调用是 ObjectOutputStream 的 defaultWriteObject方法以及 ObjectInputStream 的 defaultReadObject 方法。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">用户自定义的 writeObject 和 readObject 方法可以允许用户控制序列化的过程,比如可以在序列化的过程中动态改变序列化的数值。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">所以,对于一些特殊字段需要定义序列化的策略的时候,可以考虑使用transient修饰,并自己重写writeObject 和 readObject 方法,如java.util.ArrayList中就有这样的实现。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">以上,就是一些读者需要掌握和和序列化有关的知识。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">我们随便找几个Java中实现了序列化接口的类,如String、Integer等,我们可以发现一个细节,那就是这些类除了实现了Serializable外,还定义了一个serialVersionUID</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><img class="" data-ratio="0.27191679049034173" data-type="other" data-w="673" data-src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4Zt3oib2h4ZFQPiavOt0mKtZr6IUdQKJibibt6iawemcP9G0KXXgibaGb2wekA/640?wx_fmt=other" style="visibility: visible !important; width: 673px !important; height: auto !important;" _width="673px" src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4Zt3oib2h4ZFQPiavOt0mKtZr6IUdQKJibibt6iawemcP9G0KXXgibaGb2wekA/640?wx_fmt=other&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" crossorigin="anonymous" data-fail="0"></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">那么,到底什么是serialVersionUID呢?为什么要设置这样一个字段呢?</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><strong style="color: rgb(191, 54, 12);">什么是serialVersionUID</strong></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><strong style="color: rgb(191, 54, 12);">序列化是将对象的状态信息转换为可存储或传输的形式的过程。我们都知道,Java对象是保存在JVM的堆内存中的,也就是说,如果JVM堆不存在了,那么对象也就跟着消失了。</strong></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">而序列化提供了一种方案,可以让你在即使JVM停机的情况下也能把对象保存下来的方案。就像我们平时用的U盘一样。把Java对象序列化成可存储或传输的形式(如二进制流),比如保存在文件中。这样,当再次需要这个对象的时候,从文件中读取出二进制流,再从二进制流中反序列化出对象。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><strong style="color: rgb(191, 54, 12);">虚拟机是否允许反序列化,不仅取决于类路径和功能代码是否一致,一个非常重要的一点是两个类的序列化 ID 是否一致</strong>,这个所谓的序列化ID,就是我们在代码中定义的serialVersionUID。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><strong style="color: rgb(191, 54, 12);">如果serialVersionUID变了会怎样</strong></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><strong style="color: rgb(191, 54, 12);">我们举个例子吧,看看如果serialVersionUID被修改了会发生什么?</strong></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><img class="" data-ratio="0.8105263157894737" data-type="other" data-w="665" data-src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4ZpEiasXYkMiaGzbI67iavd5b9BMibFm0xIuEboDJFeTma5tqhTbrSvL312w/640?wx_fmt=other" style="visibility: visible !important; width: 665px !important; height: auto !important;" _width="665px" src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4ZpEiasXYkMiaGzbI67iavd5b9BMibFm0xIuEboDJFeTma5tqhTbrSvL312w/640?wx_fmt=other&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" crossorigin="anonymous" data-fail="0"></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">我们先执行以上代码,把一个User1对象写入到文件中。然后我们修改一下User1类,把serialVersionUID的值改为2L。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><img class="" data-ratio="0.35993975903614456" data-type="other" data-w="664" data-src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4ZLSHT5gBLbM7UCJAdj29azoWxtz6SrrC90Clxj1lMfLWnSlSJ2UMqsA/640?wx_fmt=other" style="visibility: visible !important; width: 664px !important; height: auto !important;" _width="664px" src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4ZLSHT5gBLbM7UCJAdj29azoWxtz6SrrC90Clxj1lMfLWnSlSJ2UMqsA/640?wx_fmt=other&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" crossorigin="anonymous" data-fail="0"></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">然后执行以下代码,把文件中的对象反序列化出来:</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><img class="" data-ratio="0.8026905829596412" data-type="other" data-w="669" data-src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4ZzAr71KicemvmQIjh1y3u6y7vQ0xeWaicgT5sjTyS2ZwjJJK9KTFniaaeg/640?wx_fmt=other" style="visibility: visible !important; width: 669px !important; height: auto !important;" _width="669px" src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4ZzAr71KicemvmQIjh1y3u6y7vQ0xeWaicgT5sjTyS2ZwjJJK9KTFniaaeg/640?wx_fmt=other&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" crossorigin="anonymous" data-fail="0"></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">执行结果如下:</section><blockquote style="margin: 10px 5px 10px 1em;padding-top: 0px;padding-right: 10px;border-left-width: 2px;border-left-color: rgb(0, 150, 136);color: rgb(119, 119, 119);font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);letter-spacing: 1.4px;quotes: none;"><section style="line-height: 2em;margin: 1.5em 5px !important;"><span style="font-size: 12px;">java.io.InvalidClassException: com.hollis.User1; local class incompatible: stream classdesc serialVersionUID = 1, local class serialVersionUID = 2</span></section></blockquote><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">可以发现,以上代码抛出了一个java.io.InvalidClassException,并且指出serialVersionUID不一致。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">这是因为,在进行反序列化时,JVM会把传来的字节流中的serialVersionUID与本地相应实体类的serialVersionUID进行比较,如果相同就认为是一致的,可以进行反序列化,否则就会出现序列化版本不一致的异常,即是InvalidCastException。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">这也是《阿里巴巴Java开发手册》中规定,在兼容性升级中,在修改类的时候,不要修改serialVersionUID的原因。<strong style="color: rgb(191, 54, 12);">除非是完全不兼容的两个版本</strong>。所以,<strong style="color: rgb(191, 54, 12);">serialVersionUID其实是验证版本一致性的。</strong></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">如果读者感兴趣,可以把各个版本的JDK代码都拿出来看一下,那些向下兼容的类的serialVersionUID是没有变化过的。比如String类的serialVersionUID一直都是-6849794470754667710L。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">但是,作者认为,这个规范其实还可以再严格一些,那就是规定:</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">如果一个类实现了Serializable接口,就必须手动添加一个private static final long serialVersionUID变量,并且设置初始值。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><strong style="color: rgb(191, 54, 12);">为什么要明确定一个serialVersionUID</strong></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><strong style="color: rgb(191, 54, 12);">如果我们没有在类中明确的定义一个serialVersionUID的话,看看会发生什么。</strong></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">尝试修改上面的demo代码,先使用以下类定义一个对象,该类中不定义serialVersionUID,将其写入文件。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><img class="" data-ratio="0.25487256371814093" data-type="other" data-w="667" data-src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4ZlrAkn283vqJ4QU7YBgACYpx16oEoC51OZlC9sqo589xq5icO8gE7ibIw/640?wx_fmt=other" style="visibility: visible !important; width: 667px !important; height: auto !important;" _width="667px" src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4ZlrAkn283vqJ4QU7YBgACYpx16oEoC51OZlC9sqo589xq5icO8gE7ibIw/640?wx_fmt=other&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" crossorigin="anonymous" data-fail="0"></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">然后我们修改User1类,向其中增加一个属性。在尝试将其从文件中读取出来,并进行反序列化。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><img class="" data-ratio="0.44328358208955226" data-type="other" data-w="670" data-src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4Zl1DBo8xNFIcssWT4iam1LQbR95q8R5CyUiaIpN8rAYIeuejOovGiaXBeg/640?wx_fmt=other" style="visibility: visible !important; width: 670px !important; height: auto !important;" _width="670px" src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4Zl1DBo8xNFIcssWT4iam1LQbR95q8R5CyUiaIpN8rAYIeuejOovGiaXBeg/640?wx_fmt=other&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" crossorigin="anonymous" data-fail="0"></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">执行结果:</section><blockquote style="margin: 10px 5px 10px 1em;padding-top: 0px;padding-right: 10px;border-left-width: 2px;border-left-color: rgb(0, 150, 136);color: rgb(119, 119, 119);font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);letter-spacing: 1.4px;quotes: none;"><section style="line-height: 2em;margin: 1.5em 5px !important;"><span style="font-size: 12px;">java.io.InvalidClassException: com.hollis.User1; local class incompatible: stream classdesc serialVersionUID = -2986778152837257883, local class serialVersionUID = 7961728318907695402</span></section></blockquote><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">同样,抛出了InvalidClassException,并且指出两个serialVersionUID不同,分别是-2986778152837257883和7961728318907695402。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">从这里可以看出,系统自己添加了一个serialVersionUID。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">所以,一旦类实现了Serializable,就建议明确的定义一个serialVersionUID。不然在修改类的时候,就会发生异常。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">serialVersionUID有两种显示的生成方式:</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">一种是默认的1L,比如:</section><blockquote style="margin: 10px 5px 10px 1em;padding-top: 0px;padding-right: 10px;border-left-width: 2px;border-left-color: rgb(0, 150, 136);color: rgb(119, 119, 119);font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);letter-spacing: 1.4px;quotes: none;"><section style="line-height: 2em;margin: 1.5em 5px !important;"><span style="font-size: 12px;">private static final long serialVersionUID = 1L;</span></section></blockquote><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">另外一种是根据类名、接口名、成员方法及属性等来生成一个64位的哈希字段,比如:</section><blockquote style="margin: 10px 5px 10px 1em;padding-top: 0px;padding-right: 10px;border-left-width: 2px;border-left-color: rgb(0, 150, 136);color: rgb(119, 119, 119);font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);letter-spacing: 1.4px;quotes: none;"><section style="line-height: 2em;margin: 1.5em 5px !important;"><span style="font-size: 12px;">private static final long serialVersionUID = xxxxL;</span></section></blockquote><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">后面这种方式,可以借助IDE生成,后面会介绍。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><strong style="color: rgb(191, 54, 12);">背后原理</strong></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">知其然,要知其所以然,我们再来看看源码,分析一下为什么serialVersionUID改变的时候会抛异常?在没有明确定义的情况下,默认的serialVersionUID是怎么来的?</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">为了简化代码量,反序列化的调用链如下:</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><img class="" data-ratio="0.22388059701492538" data-type="other" data-w="670" data-src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4Z7eNHz4ER9su66rs1fd6Duj2e0KYXG2gQgZc4X4Q9ZAwWnVekPTsjlw/640?wx_fmt=other" style="visibility: visible !important; width: 670px !important; height: auto !important;" _width="670px" src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4Z7eNHz4ER9su66rs1fd6Duj2e0KYXG2gQgZc4X4Q9ZAwWnVekPTsjlw/640?wx_fmt=other&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" crossorigin="anonymous" data-fail="0"></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">在initNonProxy中 ,关键代码如下:</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><img class="" data-ratio="1.1997439180537772" data-type="other" data-w="781" data-src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4ZXvDSmHMtHSia6rE503uF0SHuAZaDNqWFg0ibicTKzAiaso7OrtCza8CedQ/640?wx_fmt=other" style="visibility: visible !important; width: 677px !important; height: auto !important;" _width="677px" src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4ZXvDSmHMtHSia6rE503uF0SHuAZaDNqWFg0ibicTKzAiaso7OrtCza8CedQ/640?wx_fmt=other&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" crossorigin="anonymous" data-fail="0"></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">在反序列化过程中,对serialVersionUID做了比较,如果发现不相等,则直接抛出异常。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">深入看一下getSerialVersionUID方法:</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><img class="" data-ratio="0.46038863976083705" data-type="other" data-w="669" data-src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4ZQmsAoOYkoCzKTlpztBf3CJGW1HrAgQIe4eBlG4BPQj8qc4wcEOnfcQ/640?wx_fmt=other" style="visibility: visible !important; width: 669px !important; height: auto !important;" _width="669px" src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4ZQmsAoOYkoCzKTlpztBf3CJGW1HrAgQIe4eBlG4BPQj8qc4wcEOnfcQ/640?wx_fmt=other&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" crossorigin="anonymous" data-fail="0"></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">在没有定义serialVersionUID的时候,会调用computeDefaultSUID 方法,生成一个默认的serialVersionUID。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">这也就找到了以上两个问题的根源,其实是代码中做了严格的校验,并且在未定义的时候自动生成了一个serialVersionUID。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><strong style="color: rgb(191, 54, 12);">IDEA提示</strong></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">为了确保我们不会忘记定义serialVersionUID,可以调节一下Intellij IDEA的配置,在实现Serializable接口后,如果没定义serialVersionUID的话,IDEA(eclipse一样)会进行提示:</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><img class="" data-ratio="0.2564516129032258" data-type="other" data-w="620" data-src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4ZLadFb2HFXQFpzsvJHtObH8MNrS4iabKqPXRORG2nTyCW6Eiaw3dIF2Yg/640?wx_fmt=other" style="visibility: visible !important; width: 620px !important; height: auto !important;" _width="620px" src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4ZLadFb2HFXQFpzsvJHtObH8MNrS4iabKqPXRORG2nTyCW6Eiaw3dIF2Yg/640?wx_fmt=other&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" crossorigin="anonymous" data-fail="0"></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">并且可以一键生成一个:</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><img class="" data-ratio="0.27364864864864863" data-type="other" data-w="592" data-src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4Zn0ZnVia7X4obR4GfTuwAIettiavtaR8KIQluZSEOYmFCvgHicwKsSicCMA/640?wx_fmt=other" style="visibility: visible !important; width: 592px !important; height: auto !important;" _width="592px" src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4Zn0ZnVia7X4obR4GfTuwAIettiavtaR8KIQluZSEOYmFCvgHicwKsSicCMA/640?wx_fmt=other&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" crossorigin="anonymous" data-fail="0"></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">当然,这个配置并不是默认生效的,需要手动到IDEA中设置一下:</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><img class="" data-ratio="0.525" data-type="other" data-w="1080" data-src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4ZrmkyBBG8c5ZKkajaI6MMGv2wBuvYEOAclKDJ6m70zucXEFD5SuDHEg/640?wx_fmt=other" style="visibility: visible !important; width: 677px !important; height: auto !important;" _width="677px" src="https://mmbiz.qpic.cn/mmbiz/CvQa8Yf8vq11tWicgbQ0jTiaGle6Dibibo4ZrmkyBBG8c5ZKkajaI6MMGv2wBuvYEOAclKDJ6m70zucXEFD5SuDHEg/640?wx_fmt=other&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" crossorigin="anonymous" data-fail="0"></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">在图中标号3的地方(Serializable class without serialVersionUID的配置),打上勾,保存即可。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;"><strong style="color: rgb(191, 54, 12);">总结</strong></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">serialVersionUID是用来验证版本一致性的。所以<strong style="color: rgb(191, 54, 12);">在做兼容性升级的时候,不要改变类中serialVersionUID的值。</strong></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">特别说明一下,由于本文标题并不完全能表达本文的全部内容,这里再强调一下:serialVersionUID <strong style="color: rgb(191, 54, 12);">既然是验证版本一致性的,在做版本升级的时候(非兼容性升级),记得要修改这个字段的值哦,这样可以避免序列化混乱。</strong></section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">如果一个类实现了Serializable接口,一定要记得定义serialVersionUID,否则会发生异常。可以在IDE中通过设置,让他帮忙提示,并且可以一键快速生成一个serialVersionUID。</section><section style="font-family: -apple-system-font, system-ui, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei UI', 'Microsoft YaHei', Arial, sans-serif;white-space: normal;background-color: rgb(255, 255, 255);font-size: 14px;letter-spacing: 1.4px;line-height: 2em;margin: 1.5em 5px !important;">之所以会发生异常,是因为反序列化过程中做了校验,并且如果没有明确定义的话,会根据类名及属性等自动生成一个。</section><section class="" mpa-from-tpl="t"><section class="" mpa-from-tpl="t"><section class="" powered-by="xiumi.us" mpa-from-tpl="t"><section class="" mpa-from-tpl="t"><section class="" mpa-from-tpl="t"><section class="" mpa-from-tpl="t"><section class="" data-tools="135编辑器" data-id="89428" mpa-from-tpl="t"><section mpa-from-tpl="t"><section mpa-from-tpl="t"><section data-mpa-template="t" class="" mpa-paragraph-type="ignored" style="letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);font-family: 'Helvetica Neue', Helvetica, 'Hiragino Sans GB', 'Microsoft YaHei', Arial, sans-serif;widows: 1;color: rgb(62, 62, 62);font-size: 16px;"><section><section><section><section data-mpa-template-id="692363" data-mpa-color="null" data-mpa-category="fav"><section><section><section><p style="letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-align: center;word-spacing: 2px;color: rgb(89, 89, 89);font-size: 16px;font-family: 微软雅黑;line-height: 1.75em;"><img class="" data-ratio="0.45454545454545453" data-w="22" title="音符" data-src="https://mmbiz.qpic.cn/mmbiz/cZV2hRpuAPiaJQXWGyC9wrUzIicibgXayrgibTYarT3A1yzttbtaO0JlV21wMqroGYT3QtPq2C7HMYsvicSB2p7dTBg/640?" style="font-variant-numeric: normal; letter-spacing: 0.544px; line-height: 25.6px; widows: 1; display: inline; visibility: visible !important; width: auto !important; height: auto !important;" _width="auto" src="https://mmbiz.qpic.cn/mmbiz/cZV2hRpuAPiaJQXWGyC9wrUzIicibgXayrgibTYarT3A1yzttbtaO0JlV21wMqroGYT3QtPq2C7HMYsvicSB2p7dTBg/640?tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" crossorigin="anonymous" data-fail="0"></p><section powered-by="xiumi.us" style="white-space: normal;background-color: rgb(255, 255, 255);color: rgb(30, 29, 29);font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;font-size: 15px;letter-spacing: 2px;text-align: center;word-spacing: 2px;"><p><strong style="font-family: 微软雅黑;font-size: 16px;letter-spacing: 0.544px;"><span style="caret-color: red;font-size: 15px;color: rgb(0, 122, 170);"><strong style="font-size: 16px;letter-spacing: 0.544px;"><span style="caret-color: red;font-size: 15px;"><span style="letter-spacing: 0.544px;">有热门推荐</span><span style="font-family: -apple-system-font, BlinkMacSystemFont, Arial, sans-serif;letter-spacing: 0.544px;">?</span></span></strong></span></strong></p></section><section powered-by="xiumi.us" style="margin-top: 10px;margin-bottom: 10px;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;word-spacing: 2px;color: rgb(89, 89, 89);font-size: 16px;text-align: left;"><section style="padding: 10px;display: inline-block;width: 556px;border-width: 2px;border-style: dotted;border-color: rgb(192, 200, 209);"><section powered-by="xiumi.us" style="font-size: 13px;line-height: 2;"><p style="letter-spacing: 2px;color: rgb(106, 104, 111);">1.&nbsp;<a href="https://mp.weixin.qq.com/s?__biz=MzI2OTQxMTM4OQ==&amp;mid=2247490011&amp;idx=1&amp;sn=5312477b531bc0d21d703d924e828175&amp;chksm=eae1ec89dd96659f37dbbd8ab0791ad684f2543912cf81dcefb05fc357d35570293fd775a638&amp;token=684884169&amp;lang=zh_CN&amp;scene=21#wechat_redirect" target="_blank" data-linktype="2" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);cursor: pointer;"><span style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="letter-spacing: 1px;">面试官问我:</span></span><span style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"><span style="letter-spacing: 1px;">一个 TCP 连接可以发多少个 HTTP 请求?我竟然回答不上来...</span></span><span style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></span></a></p><p><span style="color: rgb(106, 104, 111);"><span style="letter-spacing: 2px;">2.</span><span style="letter-spacing: 1px;">&nbsp;<a href="https://mp.weixin.qq.com/s?__biz=MzI2OTQxMTM4OQ==&amp;mid=2247490024&amp;idx=2&amp;sn=3b8a42d0e9aae286984c03a5ac0b3389&amp;chksm=eae1ecbadd9665ace47c2ce20487852a38dfe3735a0ee74d38096af7f7d38c862373a83e90a9&amp;token=998583159&amp;lang=zh_CN&amp;scene=21#wechat_redirect" target="_blank" data-linktype="2" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);cursor: pointer;"><span style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">不敢相信?</span><span style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);">System.currentTimeMillis() 居然存在性能问题</span></a></span></span><span style="color: rgb(106, 104, 111);letter-spacing: 2px;"></span></p><p style="letter-spacing: 2px;color: rgb(106, 104, 111);">3.&nbsp;<a href="https://mp.weixin.qq.com/s?__biz=MzI2OTQxMTM4OQ==&amp;mid=2247490021&amp;idx=1&amp;sn=507f0ae4eb7f2baf2e7f628689715e10&amp;chksm=eae1ecb7dd9665a17d6a7be3b1978be8228a14ce778f104819b8906849190a79f6ea00d704e0&amp;token=998583159&amp;lang=zh_CN&amp;scene=21#wechat_redirect" target="_blank" data-linktype="2" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);cursor: pointer;">GitHub 标星 3.2w!</a><a href="https://mp.weixin.qq.com/s?__biz=MzI2OTQxMTM4OQ==&amp;mid=2247490021&amp;idx=1&amp;sn=507f0ae4eb7f2baf2e7f628689715e10&amp;chksm=eae1ecb7dd9665a17d6a7be3b1978be8228a14ce778f104819b8906849190a79f6ea00d704e0&amp;token=998583159&amp;lang=zh_CN&amp;scene=21#wechat_redirect" target="_blank" data-linktype="2" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);cursor: pointer;">史上最全技术面试手册!</a></p><p style="letter-spacing: 2px;color: rgb(106, 104, 111);">4.&nbsp;<a href="https://mp.weixin.qq.com/s?__biz=MzI2OTQxMTM4OQ==&amp;mid=2247489891&amp;idx=2&amp;sn=ab909c05dcb22aea0b4859165e1da341&amp;chksm=eae1ec31dd966527afe4f7d7e7b53f47d5eefd1c62bab8c53c207f2ebb2c870f909f2d95a740&amp;token=684884169&amp;lang=zh_CN&amp;scene=21#wechat_redirect" target="_blank" data-linktype="2" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);cursor: pointer;">面试常考:</a><a href="https://mp.weixin.qq.com/s?__biz=MzI2OTQxMTM4OQ==&amp;mid=2247489891&amp;idx=2&amp;sn=ab909c05dcb22aea0b4859165e1da341&amp;chksm=eae1ec31dd966527afe4f7d7e7b53f47d5eefd1c62bab8c53c207f2ebb2c870f909f2d95a740&amp;token=684884169&amp;lang=zh_CN&amp;scene=21#wechat_redirect" target="_blank" data-linktype="2" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);cursor: pointer;">Java中synchronized和volatile有什么区别?</a></p><p style="letter-spacing: 2px;color: rgb(106, 104, 111);">5.&nbsp;<a href="https://mp.weixin.qq.com/s?__biz=MzI2OTQxMTM4OQ==&amp;mid=2247489963&amp;idx=3&amp;sn=34969485fab13ee91be531c0b8b250e0&amp;chksm=eae1ecf9dd9665ef929fb4ca2bc714d69fa259b31c9d0374048858767bee13811c284ab128fe&amp;token=998583159&amp;lang=zh_CN&amp;scene=21#wechat_redirect" target="_blank" data-linktype="2" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);cursor: pointer;">Spring 常犯的十大错误,打死都不要犯!</a></p><p style="letter-spacing: 2px;color: rgb(106, 104, 111);">6.&nbsp;<a href="https://mp.weixin.qq.com/s?__biz=MzI2OTQxMTM4OQ==&amp;mid=2247489999&amp;idx=3&amp;sn=2a4cd60a1eff3ddb12d75f2da5501e88&amp;chksm=eae1ec9ddd96658b684cdc770be51ecce1ae8bba28da0e30b6245708522e23c22a0bda0bc6a6&amp;token=998583159&amp;lang=zh_CN&amp;scene=21#wechat_redirect" target="_blank" data-linktype="2" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);cursor: pointer;">Java 线程池 ThreadPoolExecutor 八种拒绝策略浅析</a></p></section></section></section><section class="" style="white-space: normal;background-color: rgb(255, 255, 255);font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;font-size: 15px;letter-spacing: 2px;text-align: center;word-spacing: 2px;color: rgb(62, 62, 62);line-height: 1.8;"><p style="margin-top: 1.7em;margin-bottom: 1.7em;font-size: inherit;color: inherit;line-height: inherit;text-align: left;"><span style="color: inherit;font-size: inherit;">句题外话,有不少人想加鱼哥微信,鱼哥姑且放出来,但是坑位有限哦</span></p></section><p style="white-space: normal;background-color: rgb(255, 255, 255);font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;font-size: 15px;letter-spacing: 2px;text-align: center;word-spacing: 2px;color: rgb(62, 62, 62);"><img class="rich_pages " data-copyright="0" data-cropselx1="0" data-cropselx2="182" data-cropsely1="0" data-cropsely2="208" data-ratio="1.1826923076923077" data-s="300,640" data-type="png" data-w="312" data-src="https://mmbiz.qpic.cn/mmbiz_png/WGyNiboAjLV4aAOhesUDJAUMy5hgrCsuvITVoUxnTg0l7JXic3D7zUqvwZddibG7teYRUUDM914GDQ6zXQ7Gu1DJQ/640?wx_fmt=png" style="visibility: visible !important; width: 182px !important; height: auto !important;" _width="182px" src="https://mmbiz.qpic.cn/mmbiz_png/WGyNiboAjLV4aAOhesUDJAUMy5hgrCsuvITVoUxnTg0l7JXic3D7zUqvwZddibG7teYRUUDM914GDQ6zXQ7Gu1DJQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" crossorigin="anonymous" data-fail="0"></p><p style="white-space: normal;background-color: rgb(255, 255, 255);font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;font-size: 15px;letter-spacing: 2px;text-align: center;word-spacing: 2px;color: rgb(62, 62, 62);"><span style="color: rgb(255, 76, 65);"><strong>想去大厂么?</strong><strong>来加入鱼哥技术星球,放大你进大厂概率</strong></span></p><p style="font-family: -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);"><br></p><section style="white-space: normal;background-color: rgb(255, 255, 255);font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;font-size: 15px;letter-spacing: 2px;text-align: center;word-spacing: 2px;color: rgb(62, 62, 62);"><span style="text-align: left;">扫描如下二维码加入我的知识星球:</span><img class="rich_pages " data-copyright="0" data-ratio="0.5059523809523809" data-s="300,640" data-type="png" data-w="672" data-src="https://mmbiz.qpic.cn/mmbiz_png/WGyNiboAjLV6kicPia1oaMpZa2O6FnujmMUPUC255yL3VnqH7vCqicnHyvaThStTdVYicBFvJpgPn5PiccHjSbgdWMUg/640?wx_fmt=png" style="font-family: -apple-system-font, BlinkMacSystemFont, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif; letter-spacing: 0.544px; text-align: left; visibility: visible !important; width: 672px !important; height: auto !important;" _width="672px" src="https://mmbiz.qpic.cn/mmbiz_png/WGyNiboAjLV6kicPia1oaMpZa2O6FnujmMUPUC255yL3VnqH7vCqicnHyvaThStTdVYicBFvJpgPn5PiccHjSbgdWMUg/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" crossorigin="anonymous" data-fail="0"></section><section data-role="paragraph" class="" style="letter-spacing: 0.544px;white-space: normal;background-color: rgb(255, 255, 255);text-align: center;word-spacing: 2px;font-size: 16px;color: rgb(63, 63, 63);font-family: Avenir, -apple-system-font, 微软雅黑, sans-serif;"><section><img class="rich_pages " data-ratio="0.5" data-s="300,640" data-type="png" data-w="800" data-src="https://mmbiz.qpic.cn/mmbiz_png/WGyNiboAjLV4IbAxNRglMcp1AvYI0hHgk4miaD6yf6cFfqn2U6bxLjBec97bjtwNr5K55XQYywR5zK7ldZDJ5XFw/640?wx_fmt=png" style="color: rgb(62, 62, 62); font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif; font-size: 15px; letter-spacing: 2px; visibility: visible !important; width: 677px !important; height: auto !important;" _width="677px" src="https://mmbiz.qpic.cn/mmbiz_png/WGyNiboAjLV4IbAxNRglMcp1AvYI0hHgk4miaD6yf6cFfqn2U6bxLjBec97bjtwNr5K55XQYywR5zK7ldZDJ5XFw/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" crossorigin="anonymous" data-fail="0"></section></section></section></section></section></section></section></section></section></section></section></section></section></section></section></section></section></section></section>
                </div>
                <script nonce="" type="text/javascript">
                    var first_sceen__time = (+new Date());

                    if ("" == 1 && document.getElementById('js_content')) {
                        document.getElementById('js_content').addEventListener("selectstart",function(e){ e.preventDefault(); });
                    }

                    
                    (function(){
                        if (navigator.userAgent.indexOf("WindowsWechat") != -1){
                            var link = document.createElement('link');
                            var head = document.getElementsByTagName('head')[0];
                            link.rel = 'stylesheet';
                            link.type = 'text/css';
                            link.href = "//res.wx.qq.com/mmbizwap/zh_CN/htmledition/style/page/appmsg_new/winwx473e11.css";
                            head.appendChild(link);
                        }
                    })();
                </script>

                
  <div class="ct_mpda_wrp" id="js_sponsor_ad_area" style="display: none;"></div>


                
                <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 class="reward-avatar" style="display: none;" id="js_preview_reward_author_avatar">
                        <img src="" alt="" id="js_preview_reward_author_head">
                    </div>
                    
                                        <div class="reward-author" id="js_preview_reward_author_name">Hollis</div>
                                        <p class="reward_tips" id="js_preview_reward_author_wording" style="display:none;"></p>
                    <p class="reward_button_wrp">
                    
                      <span class="reward_pop_panel">
                        <img src="https://res.wx.qq.com/mpres/zh_CN/htmledition/pages/home/index/pic_mp_app4290ba.png" alt="">
                        <strong>扫一扫下载订阅号助手,用手机发文章</strong>
                      </span>
                        <a class="reward_button" id="js_preview_reward_author_link" href="##"><span id="js_preview_reward_link_text">赞赏</span></a>
                    </p>
                </div>
                            </div>

<h4>转载自微信公众号,侵删</h4>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值