<h1 style="box-sizing: border-box;margin-bottom: 1rem;color: rgb(21, 153, 87);line-height: 1.35;font-size: 26px;text-align: start;white-space: normal;font-family: Menlo, Monaco, 'Source Code Pro', Consolas, Inconsolata, 'Ubuntu Mono', 'DejaVu Sans Mono', 'Courier New', 'Droid Sans Mono', 'Hiragino Sans GB', 微软雅黑, monospace !important;" data-mpa-powered-by="yiban.io">缘起</h1><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">有一次开发过程中,刚好看到小伙伴在调用 set 方法,将数据库中查询出来的 Po 对象的<strong>属性拷贝</strong>到 Vo 对象中,类似这样:</p><p style="text-align: center;"><img class="rich_pages " data-copyright="0" data-ratio="0.48936170212765956" data-s="300,640" data-type="png" data-w="846" data-src="https://mmbiz.qpic.cn/mmbiz_png/BS5J4xBO9sq6vgxve2QZn7CibSBCH30MMmxicZ1cQbibrEQJicWaialeAKnicCqKkhVH719kOiaibQibh5ZGghmYgzHb7Zw/640?wx_fmt=png" style="width: 677px !important; height: auto !important; visibility: visible !important;" _width="677px" src="https://mmbiz.qpic.cn/mmbiz_png/BS5J4xBO9sq6vgxve2QZn7CibSBCH30MMmxicZ1cQbibrEQJicWaialeAKnicCqKkhVH719kOiaibQibh5ZGghmYgzHb7Zw/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="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">可以看出,Po 和 Vo 两个类的字段绝大部分是一样的,我们一个个地调用 set 方法只是做了一些重复的冗长的操作。<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">这种操作非常容易出错,因为对象的属性太多,有可能会漏掉一两个,而且肉眼很难察觉</strong>。</p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">类似这样的操作,我们很容易想到可以通过反射来解决。其实,如此普遍通用的功能,一个&nbsp;<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">BeanUtils</strong>&nbsp;工具类就可以搞定了。</p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">于是我建议这位小伙伴了解一下 BeanUtils,后来他使用了 Apache BeanUtils.copyProperties 进行属性拷贝,这为程序<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">挖了一个坑</strong>!</p><h1 style="box-sizing: border-box;margin-top: 1.5rem;margin-bottom: 1rem;color: rgb(21, 153, 87);line-height: 1.35;font-size: 26px;text-align: start;white-space: normal;font-family: Menlo, Monaco, 'Source Code Pro', Consolas, Inconsolata, 'Ubuntu Mono', 'DejaVu Sans Mono', 'Courier New', 'Droid Sans Mono', 'Hiragino Sans GB', 微软雅黑, monospace !important;">阿里代码规约</h1><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">当我们开启阿里代码扫描插件时,如果你使用了 Apache BeanUtils.copyProperties 进行属性拷贝,它会给你一个<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">非常严重的警告</strong>。因为,<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">Apache BeanUtils性能较差,可以使用 Spring BeanUtils 或者 Cglib BeanCopier 来代替</strong>。</p><p style="text-align: center;"><img class="rich_pages " data-copyright="0" data-ratio="0.33984375" data-s="300,640" data-type="png" data-w="1280" data-src="https://mmbiz.qpic.cn/mmbiz_png/BS5J4xBO9sq6vgxve2QZn7CibSBCH30MMestnARz1PiavibSibic666ztzAMeJaUJrRfYxd0Vf2sFvK8yNEamqpdH6Q/640?wx_fmt=png" style="width: 677px !important; height: auto !important; visibility: visible !important;" _width="677px" src="https://mmbiz.qpic.cn/mmbiz_png/BS5J4xBO9sq6vgxve2QZn7CibSBCH30MMestnARz1PiavibSibic666ztzAMeJaUJrRfYxd0Vf2sFvK8yNEamqpdH6Q/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="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">看到这样的警告,有点让人有点不爽。大名鼎鼎的 Apache 提供的包,居然会存在<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">性能问题</strong>,以致于阿里给出了严重的警告。</p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">那么,这个<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">性能问题究竟是有多严重</strong>呢?毕竟,在我们的应用场景中,如果只是很微小的性能损耗,但是能带来非常大的便利性,还是可以接受的。</p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">带着这个问题。我们来做一个实验,验证一下。</p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">如果对具体的测试方式没有兴趣,可以<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">跳过直接看结果</strong>哦~</p><h2 style="box-sizing: border-box;margin-top: 1.5rem;margin-bottom: 1rem;color: rgb(21, 153, 87);line-height: 1.35;font-size: 22px;text-align: start;white-space: normal;font-family: Menlo, Monaco, 'Source Code Pro', Consolas, Inconsolata, 'Ubuntu Mono', 'DejaVu Sans Mono', 'Courier New', 'Droid Sans Mono', 'Hiragino Sans GB', 微软雅黑, monospace !important;">测试方法接口和实现定义</h2><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">首先,为了测试方便,让我们来定义一个接口,并提供各种实现:</p><pre class="" style="box-sizing: border-box;padding-top: 8px;padding-bottom: 6px;background: rgb(255, 255, 255);border-radius: 0px;overflow-y: auto;color: rgb(80, 97, 109);text-align: start;font-size: 10px;line-height: 12px;font-family: consolas, menlo, courier, monospace, 'Microsoft Yahei'!important;border-width: 1px !important;border-style: solid !important;border-color: rgb(226, 226, 226) !important;"><ol class="list-paddingleft-2" style="list-style-type: none;"><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">public interface </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">PropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    void copyProperties(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> source, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> target) throws </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Exception</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">;</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">public class </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">CglibBeanCopierPropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> implements </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">PropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">@Override</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    public void copyProperties(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> source, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> target) throws </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Exception</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">BeanCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> copier = </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">BeanCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.create(source.getClass(), target.getClass(), false);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        copier.copy(source, target, null);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(153, 153, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">// 全局静态 BeanCopier,避免每次都生成新的对象</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">public class </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">StaticCglibBeanCopierPropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> implements </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">PropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    private static </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">BeanCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> copier = </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">BeanCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.create(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Account</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.class, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Account</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.class, false);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">@Override</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    public void copyProperties(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> source, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> target) throws </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Exception</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        copier.copy(source, target, null);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">public class </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">SpringBeanUtilsPropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> implements </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">PropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">@Override</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    public void copyProperties(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> source, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> target) throws </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Exception</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        org.springframework.beans.</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">BeanUtils</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.copyProperties(source, target);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">public class </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">CommonsBeanUtilsPropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> implements </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">PropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">@Override</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    public void copyProperties(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> source, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> target) throws </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Exception</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        org.apache.commons.beanutils.</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">BeanUtils</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.copyProperties(target, source);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">}</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">public class </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">CommonsPropertyUtilsPropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> implements </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">PropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">@Override</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    public void copyProperties(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> source, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> target) throws </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Exception</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        org.apache.commons.beanutils.</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">PropertyUtils</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.copyProperties(target, source);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">}</span></code></span></p></li></ol></pre><h2 style="box-sizing: border-box;margin-top: 1.5rem;margin-bottom: 1rem;color: rgb(21, 153, 87);line-height: 1.35;font-size: 22px;text-align: start;white-space: normal;font-family: Menlo, Monaco, 'Source Code Pro', Consolas, Inconsolata, 'Ubuntu Mono', 'DejaVu Sans Mono', 'Courier New', 'Droid Sans Mono', 'Hiragino Sans GB', 微软雅黑, monospace !important;">单元测试</h2><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">然后写一个参数化的单元测试:</p><pre class="" style="box-sizing: border-box;padding-top: 8px;padding-bottom: 6px;background: rgb(255, 255, 255);border-radius: 0px;overflow-y: auto;color: rgb(80, 97, 109);text-align: start;font-size: 10px;line-height: 12px;font-family: consolas, menlo, courier, monospace, 'Microsoft Yahei'!important;border-width: 1px !important;border-style: solid !important;border-color: rgb(226, 226, 226) !important;"><ol class="list-paddingleft-2" style="list-style-type: none;"><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">@RunWith</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Parameterized</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.class)</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">public class </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">PropertiesCopierTest</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">@Parameterized</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Parameter</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">0</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">)</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    public </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">PropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> propertiesCopier;</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    </span><span class="" style="box-sizing: border-box;color: rgb(153, 153, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">// 测试次数</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    private static </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">List</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">&lt;</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Integer</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">&gt; testTimes = </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Arrays</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.asList(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">100</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">1000</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">10</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">_000, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">100</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">_000, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">1_000_000</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    </span><span class="" style="box-sizing: border-box;color: rgb(153, 153, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">// 测试结果以 markdown 表格的形式输出</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    private static </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">StringBuilder</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> resultBuilder = new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">StringBuilder</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(</span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"|实现|100|1,000|10,000|100,000|1,000,000|\n"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">).append(</span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"|----|----|----|----|----|----|\n"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">);</span></code></span></p></li><li><p><br></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">@Parameterized</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Parameters</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    public static </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Collection</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">&lt;</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">[]&gt; data() {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Collection</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">&lt;</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">[]&gt; params = new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">ArrayList</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">&lt;&gt;();</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        params.add(new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">[]{new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">StaticCglibBeanCopierPropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">()});</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        params.add(new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">[]{new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">CglibBeanCopierPropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">()});</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        params.add(new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">[]{new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">SpringBeanUtilsPropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">()});</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        params.add(new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">[]{new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">CommonsPropertyUtilsPropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">()});</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        params.add(new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">[]{new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">CommonsBeanUtilsPropertiesCopier</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">()});</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        return params;</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    }</span></code></span></p></li><li><p><br></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">@Before</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    public void setUp() throws </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Exception</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">String</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> name = propertiesCopier.getClass().getSimpleName().replace(</span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"PropertiesCopier"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">, </span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">""</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        resultBuilder.append(</span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"|"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">).append(name).append(</span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"|"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    }</span></code></span></p></li><li><p><br></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">@Test</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    public void copyProperties() throws </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Exception</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Account</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> source = new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Account</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">1</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">, </span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"test1"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">30D</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Account</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> target = new </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Account</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">();</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        </span><span class="" style="box-sizing: border-box;color: rgb(153, 153, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">// 预热一次</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        propertiesCopier.copyProperties(source, target);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        for (</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Integer</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> time : testTimes) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">            long start = </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">System</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.nanoTime();</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">            for (int i = </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">0</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">; i &lt; time; i++) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">                propertiesCopier.copyProperties(source, target);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">            }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">            resultBuilder.append((</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">System</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.nanoTime() - start) / </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">1_000_000D</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">).append(</span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"|"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        resultBuilder.append(</span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"\n"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    }</span></code></span></p></li><li><p><br></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">@AfterClass</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    public static void tearDown() throws </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Exception</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">System</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.out.println(</span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"测试结果:"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">System</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.out.println(resultBuilder);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">}</span></code></span></p></li></ol></pre><h2 style="box-sizing: border-box;margin-top: 1.5rem;margin-bottom: 1rem;color: rgb(21, 153, 87);line-height: 1.35;font-size: 22px;text-align: start;white-space: normal;font-family: Menlo, Monaco, 'Source Code Pro', Consolas, Inconsolata, 'Ubuntu Mono', 'DejaVu Sans Mono', 'Courier New', 'Droid Sans Mono', 'Hiragino Sans GB', 微软雅黑, monospace !important;">测试结果</h2><p style="text-align: center;"><img class="rich_pages " data-ratio="0.3" data-s="300,640" data-type="png" data-w="1280" data-src="https://mmbiz.qpic.cn/mmbiz_png/BS5J4xBO9sq6vgxve2QZn7CibSBCH30MMgJA4icWDJUmNqtAiaiaOtg1UAb80BblK2RDNIKApvcx7B7wjCfrnQ59nw/640?wx_fmt=png" style="width: 677px !important; height: auto !important; visibility: visible !important;" _width="677px" src="https://mmbiz.qpic.cn/mmbiz_png/BS5J4xBO9sq6vgxve2QZn7CibSBCH30MMgJA4icWDJUmNqtAiaiaOtg1UAb80BblK2RDNIKApvcx7B7wjCfrnQ59nw/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="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">结果表明,<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">Cglib 的 BeanCopier 的拷贝速度是最快的</strong>,即使是百万次的拷贝也只需要 10 毫秒! 相比而言,最差的是 Commons 包的 BeanUtils.copyProperties 方法,100 次拷贝测试与表现最好的 Cglib 相差&nbsp;<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">400 倍</strong>之多。百万次拷贝更是出现了&nbsp;<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">2600 倍的性能差异!</strong></p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">结果真是让人大跌眼镜。</p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">但是它们为什么会有这么大的差异呢?</p><h2 style="box-sizing: border-box;margin-top: 1.5rem;margin-bottom: 1rem;color: rgb(21, 153, 87);line-height: 1.35;font-size: 22px;text-align: start;white-space: normal;font-family: Menlo, Monaco, 'Source Code Pro', Consolas, Inconsolata, 'Ubuntu Mono', 'DejaVu Sans Mono', 'Courier New', 'Droid Sans Mono', 'Hiragino Sans GB', 微软雅黑, monospace !important;">原因分析</h2><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">查看源码,我们会发现 CommonsBeanUtils 主要有以下几个耗时的地方:</p><ul style="list-style-type: square;" class="list-paddingleft-2"><li><p><span style="color: rgb(74, 74, 74);box-sizing: border-box;font-size: 14px !important;">输出了大量的<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">日志</strong>调试信息</span></p></li><li><p><span style="color: rgb(74, 74, 74);box-sizing: border-box;font-size: 14px !important;">重复的对象<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">类型检查</strong></span></p></li><li><p><span style="color: rgb(74, 74, 74);box-sizing: border-box;font-size: 14px !important;"><strong style="box-sizing: border-box;color: rgb(0, 0, 0);">类型转换</strong></span></p></li></ul><pre class="" style="box-sizing: border-box;padding-top: 8px;padding-bottom: 6px;background: rgb(255, 255, 255);border-radius: 0px;overflow-y: auto;color: rgb(80, 97, 109);text-align: start;font-size: 10px;line-height: 12px;font-family: consolas, menlo, courier, monospace, 'Microsoft Yahei'!important;border-width: 1px !important;border-style: solid !important;border-color: rgb(226, 226, 226) !important;"><ol class="list-paddingleft-2" style="list-style-type: none;"><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">  public void copyProperties(final </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> dest, final </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> orig)</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        throws </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">IllegalAccessException</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">InvocationTargetException</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        </span><span class="" style="box-sizing: border-box;color: rgb(153, 153, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">// 类型检查 </span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        if (orig instanceof </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">DynaBean</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">            ...</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        } else if (orig instanceof </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Map</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">           ...</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        } else {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">            final </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">PropertyDescriptor</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">[] origDescriptors = ...</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">            for (</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">PropertyDescriptor</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> origDescriptor : origDescriptors) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">                ...</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">                </span><span class="" style="box-sizing: border-box;color: rgb(153, 153, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">// 这里每个属性都调一次 copyProperty</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">                copyProperty(dest, name, value);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">            }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    }</span></code></span></p></li><li><p><br></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    public void copyProperty(final </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> bean, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">String</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> name, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> value)</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        throws </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">IllegalAccessException</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">InvocationTargetException</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        ...</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        </span><span class="" style="box-sizing: border-box;color: rgb(153, 153, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">// 这里又进行一次类型检查</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        if (target instanceof </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">DynaBean</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">            ...</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        ...</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        </span><span class="" style="box-sizing: border-box;color: rgb(153, 153, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">// 需要将属性转换为目标类型</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        value = convertForCopy(value, type);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        ...</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    </span><span class="" style="box-sizing: border-box;color: rgb(153, 153, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">// 而这个 convert 方法在日志级别为 debug 的时候有很多的字符串拼接</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    public &lt;T&gt; T convert(final </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Class</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">&lt;T&gt; type, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> value) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        if (log().isDebugEnabled()) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">            log().debug(</span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"Converting"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> + (value == null ? </span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">""</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> : </span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">" '"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> + toString(sourceType) + </span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"'"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">) + </span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">" value '"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> + value + </span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"' to type '"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> + toString(targetType) + </span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"'"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        ...</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        if (targetType.equals(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">String</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.class)) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">            return targetType.cast(convertToString(value));</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        } else if (targetType.equals(sourceType)) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">            if (log().isDebugEnabled()) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">                log().debug(</span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"No conversion required, value is already a "</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> + toString(targetType));</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">            }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">            return targetType.cast(value);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        } else {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">            </span><span class="" style="box-sizing: border-box;color: rgb(153, 153, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">// 这个 convertToType 方法里也需要做类型检查</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">            final </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> result = convertToType(targetType, value);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">            if (log().isDebugEnabled()) {</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">                log().debug(</span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"Converted to "</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> + toString(targetType) + </span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">" value '"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> + result + </span><span class="" style="box-sizing: border-box;color: rgb(221, 17, 68);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">"'"</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">            }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">            return targetType.cast(result);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">        }</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">    }</span></code></span></p></li></ol></pre><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">具体的性能和源码分析,可以参考这几篇文章:</p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">几种copyProperties工具类性能比较:https://www.jianshu.com/p/bcbacab3b89e&nbsp;</p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">CGLIB中BeanCopier源码实现:https://www.jianshu.com/p/f8b892e08d26&nbsp;</p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">Java Bean Copy框架性能对比:https://yq.aliyun.com/articles/392185</p><h1 style="box-sizing: border-box;margin-top: 1.5rem;margin-bottom: 1rem;color: rgb(21, 153, 87);line-height: 1.35;font-size: 26px;text-align: start;white-space: normal;font-family: Menlo, Monaco, 'Source Code Pro', Consolas, Inconsolata, 'Ubuntu Mono', 'DejaVu Sans Mono', 'Courier New', 'Droid Sans Mono', 'Hiragino Sans GB', 微软雅黑, monospace !important;">One more thing</h1><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">除了性能问题之外,在使用 CommonsBeanUtils 时还有<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">其他的坑</strong>需要特别小心!</p><h2 style="box-sizing: border-box;margin-top: 1.5rem;margin-bottom: 1rem;color: rgb(21, 153, 87);line-height: 1.35;font-size: 22px;text-align: start;white-space: normal;font-family: Menlo, Monaco, 'Source Code Pro', Consolas, Inconsolata, 'Ubuntu Mono', 'DejaVu Sans Mono', 'Courier New', 'Droid Sans Mono', 'Hiragino Sans GB', 微软雅黑, monospace !important;">包装类默认值</h2><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">在进行属性拷贝时,低版本CommonsBeanUtils 为了解决Date为空的问题会导致为目标对象的<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">原始类型的包装类属性赋予初始值</strong>,如 Integer 属性默认赋值为 0,尽管你的来源对象该字段的值为 null。</p><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">这个在我们的<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">包装类属性为 null 值时有特殊含义的场景</strong>,非常容易踩坑!例如搜索条件对象,一般 null 值表示该字段不做限制,而 0 表示该字段的值必须为0。</p><h2 style="box-sizing: border-box;margin-top: 1.5rem;margin-bottom: 1rem;color: rgb(21, 153, 87);line-height: 1.35;font-size: 22px;text-align: start;white-space: normal;font-family: Menlo, Monaco, 'Source Code Pro', Consolas, Inconsolata, 'Ubuntu Mono', 'DejaVu Sans Mono', 'Courier New', 'Droid Sans Mono', 'Hiragino Sans GB', 微软雅黑, monospace !important;">改用其他工具时</h2><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">当我们看到阿里的提示,或者你看了这篇文章之后,知道了 CommonsBeanUtils 的性能问题,想要改用 Spring 的 BeanUtils 时,<strong>要特别小心</strong>:</p><pre class="" style="box-sizing: border-box;padding-top: 8px;padding-bottom: 6px;background: rgb(255, 255, 255);border-radius: 0px;overflow-y: auto;color: rgb(80, 97, 109);text-align: start;font-size: 10px;line-height: 12px;font-family: consolas, menlo, courier, monospace, 'Microsoft Yahei'!important;border-width: 1px !important;border-style: solid !important;border-color: rgb(226, 226, 226) !important;"><ol class="list-paddingleft-2" style="list-style-type: none;"><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">org.apache.commons.beanutils.</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">BeanUtils</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.copyProperties(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> target, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> source);</span></code></span></p></li><li><p><span style="box-sizing: border-box;color: rgb(74, 74, 74);display: block;font-size: 14px !important;word-break: inherit !important;"><code class="" style="box-sizing: border-box;margin-left: -20px;display: flex;overflow: initial;line-height: 12px;overflow-wrap: normal;border-width: 0px;border-style: initial;border-color: initial;font-size: 10px;font-family: inherit !important;white-space: pre !important;"><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">org.springframework.beans.</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">BeanUtils</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">.copyProperties(</span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> source, </span><span class="" style="box-sizing: border-box;color: rgb(68, 85, 136);line-height: 20px;font-size: 13px !important;white-space: inherit !important;">Object</span><span class="" style="box-sizing: border-box;color: rgb(51, 51, 51);line-height: 20px;font-size: 13px !important;white-space: inherit !important;"> target);</span></code></span></p></li></ol></pre><p style="box-sizing: border-box;margin-top: 15px;margin-bottom: 15px;color: rgb(80, 97, 109);font-family: Helvetica, Arial, sans-serif;font-size: 15px;text-align: start;white-space: normal;">从方法签名上可以看出,这<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">两个工具类的名称相同,方法名也相同,甚至连参数个数、类型、名称都相同</strong>。但是<strong style="box-sizing: border-box;color: rgb(0, 0, 0);">参数的位置是相反的</strong>。因此,如果你想更改的时候,千万要记得,将 target 和 source 两个参数也调换过来!</p>
</div>

原文地址:https://mp.weixin.qq.com/s?__biz=MzA3ODQ0Mzg2OA==&mid=2649049711&idx=1&sn=6d874638eea770918a599be2442f77de&chksm=87534e5cb024c74a3c2a0dd792ac1e85ef4c7260235ff029a812300261d230410e418a58f6c0&mpshare=1&scene=23&srcid=06115dzep7FXbo031oAmGRHn#rd

为什么阿里代码规约要求避免使用 Apache BeanUtils 进行属性复制的更多相关文章

  1. Bean映射工具之Apache BeanUtils VS Spring BeanUtils

    背景 在我们实际项目开发过程中,我们经常需要将不同的两个对象实例进行属性复制,从而基于源对象的属性信息进行后续操作,而不改变源对象的属性信息,比如DTO数据传输对象和数据对象DO,我们需要将DO对象进 ...

  2. Apache BeanUtils与Spring BeanUtils性能比较

    在我们实际项目开发过程中,我们经常需要将不同的两个对象实例进行属性复制,从而基于源对象的属性信息进行后续操作,而不改变源对象的属性信息,比如DTO数据传输对象和数据对象DO,我们需要将DO对象进行属性 ...

  3. eclipse手动安装alibaba代码规范插件+取消阿里编码规约插件扫描出来的警告及错误

    如果你的开发环境无法访问外网,那么手动安装阿里巴巴的代码规范插件是一个不错的选择.另外,很多教程说该插件需要jdk1.8以上,我试了一下jdk1.7也是可以运行的,更低的版本就不知道了,貌似jdk1. ...

  4. 安装阿里Java代码规约插件

    概述 2017年10月14日杭州云栖大会,Java代码规约扫描插件全球首发仪式正式启动,规范正式以插件形式公开走向业界,引领Java语言的规范之路.目前,插件已在云效公有云产品中集成,立即体验!(云效 ...

  5. 为什么阿里Java规约要求谨慎修改serialVersionUID字段

    serialVersionUID简要介绍 serialVersionUID是在Java序列化.反序列化对象时起作用的一个字段.Java的序列化机制是通过判断类的serialVersionUID来验证版 ...

  6. 阿里巴巴Java开发手册及Java代码规约扫描eclipse插件

    一.github地址: https://github.com/alibaba/p3c 二..eclipse插件的安装 此处示例采用eclipse,版本为 Neon.1 Release RC3 (4.6 ...

  7. eclipse安装阿里代码扫描插件

    1.首先打开eclipse软件,点击工具栏上的Help,选择Install New Soft进行安装新的插件. 2.进入插件安装界面,点击Add,弹出插件地址填写界面,也可以直接在市场上搜索关键字al ...

  8. 为什么阿里Java规约要求谨慎使用SimpleDateFormat

    前言 在阿里Java开发规约中,有强制性的提到SimpleDateFormat 是线程不安全的类 ,在使用的时候应当注意线程安全问题,如下: 其实之前已经介绍过使用JDK1.8的DateTimeFor ...

  9. 微信开发之SVN提交代码与FTP同步到apache的根目录

    SVN是协同开发的,版本控制器,就是几个人同时开发,可以提交代码到SVN服务器,这样就可以协同开发,一般是早上上班首先更新下代码,然后自己修改代码 工作一天之后,修改代码之后,下班之前,更新代码,然后 ...

随机推荐

  1. 廖雪峰Python总结4

    面向对象编程 将计算机程序视为一系列的命令集合.包含: 数据 操作数据的函数 Python中,所有的数据类型都可以视为对象. 面向对象特点:封装,继承,多态. 类的函数和普通函数:类的第一个参数永远是 ...

  2. homework-//2017-12-27 11:11 星期三

    //2017-12-27 11:11 星期三 const WEEKMAP = { 0:"sunday", 1:"monday", 2:"tuesday ...

  3. MAC+VS Code+Python+Markdown调试配置

    目录 VS Code官网下载 VS Code插件推荐 VS Code Python环境配置 Markdown配置 VS Code官方文档 VS Code官网下载 VS Code官网下载地址 VS Co ...

  4. Directx教程(24) 简单的光照模型(3)

    原文:Directx教程(24) 简单的光照模型(3)      在工程myTutorialD3D11_17中,我们重新定义我们的cube顶点法向,每个三角形面的顶点法向都是和这个三角形的面法向是一致 ...

  5. js简单倒计时

    不想每次用倒计时,都现写代码,比较烦,这里记一下,也顺便分享一些倒计时简单的逻辑. 如果你有更简单方便的代码,可以分享给大家. var method = { countdownObj: { timer ...

  6. 在Swift中检查API的可用性

    http://www.cocoachina.com/swift/20150901/13283.html 本文由CocoaChina译者ALEX吴浩文翻译自Use Your Loaf博客 原文:Chec ...

  7. git操作——git pull 撤销误操作,恢复本地代码

    需求 开发的代码还未commit到git本地仓库,就从git远程仓库上pull了代码,导致开发的代码直接被冲掉,需要退回到上一个版本代码. 操作 进入到项目git本地仓库文件夹下 打开cmd窗口,执行 ...

  8. this 、静态变量

    /*作者:qingfeng日期:2017/2/18功能:this,静态变量(类变量)*/class Demo3_2{    public static void main(String args[]) ...

  9. ROS报错:IOError:[Errno 13]permission denied: /home/neousys/.ros/roscore-11311.pid"

    在安装ROS后启动ROS,输入:roscore 时报错: 这个问题是由于该路径下ros文件权限造成的. 输入以下命令修改权限: sudo chmod -R ~/.ros/ 修改完成后再次输入rosco ...

  10. Quick BI 3.0 - 强大的多维分析表格:交叉表

    写在开头 对于普通的表格展示数据,相信大家都非常熟悉了,今天给大家介绍的是BI领域的分析利器-交叉表,这个在BI分析场景中使用占比最多的分析利器.通过交叉表对数据的承载和管理,用户可以一目了然地分析出 ...