为什么阿里代码规约要求避免使用 Apache BeanUtils 进行属性复制
<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&tp=webp&wxfrom=5&wx_lazy=1&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;">类似这样的操作,我们很容易想到可以通过反射来解决。其实,如此普遍通用的功能,一个 <strong style="box-sizing: border-box;color: rgb(0, 0, 0);">BeanUtils</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;">于是我建议这位小伙伴了解一下 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&tp=webp&wxfrom=5&wx_lazy=1&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;"><</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;">> 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;"><</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;">[]> 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;"><</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;">[]> 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;"><>();</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 < 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&tp=webp&wxfrom=5&wx_lazy=1&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 相差 <strong style="box-sizing: border-box;color: rgb(0, 0, 0);">400 倍</strong>之多。百万次拷贝更是出现了 <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 <T> 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;"><T> 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 </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 </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>
为什么阿里代码规约要求避免使用 Apache BeanUtils 进行属性复制的更多相关文章
- Bean映射工具之Apache BeanUtils VS Spring BeanUtils
背景 在我们实际项目开发过程中,我们经常需要将不同的两个对象实例进行属性复制,从而基于源对象的属性信息进行后续操作,而不改变源对象的属性信息,比如DTO数据传输对象和数据对象DO,我们需要将DO对象进 ...
- Apache BeanUtils与Spring BeanUtils性能比较
在我们实际项目开发过程中,我们经常需要将不同的两个对象实例进行属性复制,从而基于源对象的属性信息进行后续操作,而不改变源对象的属性信息,比如DTO数据传输对象和数据对象DO,我们需要将DO对象进行属性 ...
- eclipse手动安装alibaba代码规范插件+取消阿里编码规约插件扫描出来的警告及错误
如果你的开发环境无法访问外网,那么手动安装阿里巴巴的代码规范插件是一个不错的选择.另外,很多教程说该插件需要jdk1.8以上,我试了一下jdk1.7也是可以运行的,更低的版本就不知道了,貌似jdk1. ...
- 安装阿里Java代码规约插件
概述 2017年10月14日杭州云栖大会,Java代码规约扫描插件全球首发仪式正式启动,规范正式以插件形式公开走向业界,引领Java语言的规范之路.目前,插件已在云效公有云产品中集成,立即体验!(云效 ...
- 为什么阿里Java规约要求谨慎修改serialVersionUID字段
serialVersionUID简要介绍 serialVersionUID是在Java序列化.反序列化对象时起作用的一个字段.Java的序列化机制是通过判断类的serialVersionUID来验证版 ...
- 阿里巴巴Java开发手册及Java代码规约扫描eclipse插件
一.github地址: https://github.com/alibaba/p3c 二..eclipse插件的安装 此处示例采用eclipse,版本为 Neon.1 Release RC3 (4.6 ...
- eclipse安装阿里代码扫描插件
1.首先打开eclipse软件,点击工具栏上的Help,选择Install New Soft进行安装新的插件. 2.进入插件安装界面,点击Add,弹出插件地址填写界面,也可以直接在市场上搜索关键字al ...
- 为什么阿里Java规约要求谨慎使用SimpleDateFormat
前言 在阿里Java开发规约中,有强制性的提到SimpleDateFormat 是线程不安全的类 ,在使用的时候应当注意线程安全问题,如下: 其实之前已经介绍过使用JDK1.8的DateTimeFor ...
- 微信开发之SVN提交代码与FTP同步到apache的根目录
SVN是协同开发的,版本控制器,就是几个人同时开发,可以提交代码到SVN服务器,这样就可以协同开发,一般是早上上班首先更新下代码,然后自己修改代码 工作一天之后,修改代码之后,下班之前,更新代码,然后 ...
随机推荐
- Linux常用命令4 帮助命令
1.帮助命令:man 命令英文原意:manual 命令所在路径:/usr/bin/man 执行权限:所有用户 语法:man [命令或配置文件] 功能描述:获得命令或者配置文件的帮助信息 例如:m ...
- SPSS操作:轻松实现1:1倾向性评分匹配(PSM)
SPSS操作:轻松实现1:1倾向性评分匹配(PSM) 谈起临床研究,如何设立一个靠谱的对照,有时候成为整个研究成败的关键.对照设立的一个非常重要的原则就是可比性,简单说就是对照组除了研究因素外,其他的 ...
- nginx+tomcat集群+redis(memcache)session共享!
常用保持session的方式: 1.一些代理(比如nginxIP_hash) 1.使用数据库来存储Session 2.使用Cookie来存储Session ...
- scrapy 调用js
依赖: PyExecJS 使用案例: from execjs import execjs text = response.xpath('//script/text()')[1].get() ctx = ...
- springboot 自定义starter之AutoConfiguration【原】
八.自定义starter AutoConfiguration: 1.这个场景需要使用到的依赖是什么? 没有特别依赖的配置 2.如何编写自动配置 @Configuration //指定这个类是一个配置类 ...
- C++:for范围循环特点--自我理解
for(declaration : expression)statement for(xx-type i : P)....其一:for范围类型循环在循环前,可能会对p所在的队列里,对每一个对象进行一次 ...
- JDK 8 中包列表及介绍
了解了Java 8中所有包的作用,对Java 8有了一个整体的了解,另外也是提高了自身的阅读能力.本文列出了Java 8中所有的包,并且对每一个包的功能做了简要的说明,希望对你有所帮助. ------ ...
- Mac Duet使用教程
简介 Ex-Apple Engineers turn your iPad into an extra display. 下载地址 Mac duet for Mac iPad duet for iPad ...
- Python中并发前戏之操作系统
进程: 1.串行: 一个任务完完整整地运行完毕后,才能运行下一个任务 2.并发 看起来多个任务是同时运行的即可,单核也可以实现并发 3.并行: 真正意义上多个任务的同时运行,只有多核才实现并行 1.什 ...
- Maven command
mvn eclispe:clean mvn eclispe:eclispe mvn clean package mvn clean package -Dmaven.test.skip=true mvn ...