Dozer
作用:BeanUtils 的升级版,用于实现的对两个 Java Bean 对象之间进行字段的映射,从而进行实体之间的转换。
dozer 映射文件
<?xml version="1.0" encoding="UTF-8"?>
<mappings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://dozermapper.github.io/schema/bean-mapping"
xsi:schemaLocation="http://dozermapper.github.io/schema/bean-mapping
https://dozermapper.github.io/schema/bean-mapping.xsd">
<!--
可以使用map-id指定映射的标识,在程序中通过此标识来确定使用当前这个映射关系
-->
<mapping date-format="yyyy-MM-dd" map-id="user">
<class-a>org.example.model.po.UserEntity</class-a>
<class-b>org.example.model.dto.UserDTO</class-b>
<field>
<a>id</a>
<b>userId</b>
</field>
<field>
<a>name</a>
<b>userName</b>
</field>
<field>
<a>age</a>
<b>userAge</b>
</field>
</mapping>
</mappings>