BeanUtils.copyProperties 忽略id
时间: 2023-10-14 12:31:37 浏览: 171
BeanMapper:比BeanUtils.copyProperties更快
BeanUtils.copyProperties(source, target, getNullPropertyNames(source));这个方法可以复制非null属性。如果你想忽略id属性,可以在源代码中添加一个过滤器,将id属性排除在复制范围之外。可以使用BeanMapper这个类库来实现快速替代BeanUtils.copyProperties方法。BeanMapper利用javassist类库实现了高效的属性复制,避免了BeanUtils在大量调用时的性能问题。另外,需要注意的是,BeanUtils.copyProperties()在属性名相同但类型不同时,不会拷贝该属性值。所以,如果你想忽略id属性,可以在源代码中进行过滤。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [BeanUtils.copyProperties忽略null值](https://blog.csdn.net/qq_34626094/article/details/123352370)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [BeanMapper:比BeanUtils.copyProperties更快](https://download.csdn.net/download/weixin_42131785/15331636)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [java BeanUtils.copyProperties()对象拷贝忽略某个属性](https://blog.csdn.net/qq_44209563/article/details/123806208)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文