当前位置:网站首页>BeanUtils.copyProperties() 对比 mapstruct
BeanUtils.copyProperties() 对比 mapstruct
2022-06-30 17:51:00 【帅大大的架构之路】
BeanUtils.copyProperties() 对比 mapstruct
文章目录
1.深拷贝与浅拷贝的区别
浅拷贝(shallowCopy)只是增加了一个指针指向已存在的内存地址,
深拷贝(deepCopy)是增加了一个指针并且申请了一个新的内存,使这个增加的指针指向这个新的内存,
深拷贝和浅拷贝最根本的区别在于是否真正获取一个对象的复制实体,而不是引用。
假设B复制了A,修改A的时候,看B是否发生变化:
如果B跟着也变了,说明是浅拷贝,拿人手短!(修改堆内存中的同一个值)
如果B没有改变,说明是深拷贝,自食其力!(修改堆内存中的不同的值)
2.BeanUtils是深拷贝还是浅拷贝
拷贝简单对象的时候是深拷贝
拷贝复杂对象的时候(对象属性里持有对象)是浅拷贝

3.mapstruct是深拷贝还是浅拷贝
拷贝简单对象的时候是深拷贝
拷贝复杂对象的时候(对象属性里持有对象)是浅拷贝

4.BeanUtils.copyProperties() VS mapstruct 性能对比

结论
BeanUtils.copyProperties() 和 mapstruct 都是浅拷贝,区别在于两者性能不同,mapstruct 性能更好一些
涉及到拷贝字段需要更改,或作一些特殊处理的时候mapstruct提供更好的解决方法
边栏推荐
- At present, the big guys are joining the two streams of flinksql, cdcmysql and Kafka, and the results are put into MySQL or KA
- Swin-transformer --relative positional Bias
- Dlib库实现人脸关键点检测(Opencv实现)
- Nodejs 安装与介绍
- Ansi/ul 94 class 5-V vertical combustion test
- 开发那些事儿:Linux系统中如何安装离线版本MySQL?
- Full recharge, im+rtc+x full communication service "feedback season" starts
- How to improve the three passive situations in data analysis
- 华兴证券:混合云原生架构下的 Kitex 实践
- Kalman滤波器--从高斯融合推导
猜你喜欢

Practice and Thinking on the architecture of a set of 100000 TPS im integrated message system

German agbb VOC hazardous substances test

传统微服务框架如何无缝过渡到服务网格 ASM

拓维信息使用 Rainbond 的云原生落地实践

Entry node of link in linked list - linked list topic

sqlserver SQL Server Management Studio和Transact-SQL创建账户、创建访问指定数据库的只读用户

When selecting smart speakers, do you prefer "smart" or "sound quality"? This article gives you the answer

Redis入门到精通01

France a+ France VOC label highest environmental protection level

拓維信息使用 Rainbond 的雲原生落地實踐
随机推荐
mysql函数获取全路径
Coding officially entered Tencent conference application market!
GameFi链游系统开发NFT技术
一套十万级TPS的IM综合消息系统的架构实践与思考
Four tips tell you how to use SMS to promote business sales?
opencv数据类型代码表 dtype
TCP packet sticking problem
拓維信息使用 Rainbond 的雲原生落地實踐
Kalman滤波器--从高斯融合推导
CTF流量分析常见题型(二)-USB流量
com.alibaba.fastjson.JSONObject # toJSONString 消除循环引用
Evolution of screen display technology
ONEFLOW source code parsing: automatic inference of operator signature
Ambient light and micro distance detection system based on stm32f1
Electronic components bidding and purchasing Mall: optimize traditional purchasing business and speed up enterprise digital upgrading
Where do the guests come from
云上“视界” 创新无限 | 2022阿里云直播峰会正式上线
Unlimited cloud "vision" innovation | the 2022 Alibaba cloud live summit was officially launched
PC端微信多开
德国AgBB VoC有害物质测试