SpringBoot2.x 集成 Dozer

SpringBoot2.x 集成 Dozer
一、引入依赖
 
<dependency>
 
    <groupId>com.github.dozermapper</groupId>
 
    <artifactId>dozer-spring-boot-starter</artifactId>
 
    <version>6.5.0</version>
 
</dependency>
 
<dependency>
 
    <groupId>org.springframework.boot</groupId>
 
    <artifactId>spring-boot-starter-test</artifactId>
 
    <scope>test</scope>
 
</dependency>
 
<!-- lombok插件 -->
 
<dependency>
 
    <groupId>org.projectlombok</groupId>
 
    <artifactId>lombok</artifactId>
 
    <version>1.18.8</version>
 
</dependency>
 
二、实体类
 
User类:
 
package com.rtxtitanv.model;
 
import lombok.Data;
 
import lombok.experimental.Accessors;
 
import java.util.Date;
 
/**
 
 * @author rtxtitanv
 
 * @version 1.0.0
 
 * @name com.rtxtitanv.model.User
 
 * @description User
 
 * @date 2021/8/18 16:45
 
 */
 
@Accessors(chain = true)
 
@Data
 
public class User {
 
    private Long id;
 
    private String name;
 
    private Integer age;
 
    private String gender;
 
    private String email;
 
    private Date birthday;
 
}
 
UserDTO类:
 
package com.rtxtitanv.model;
 
import lombok.Data;
 
import lombok.experimental.Accessors;
 
/**
 
 * @author rtxtitanv
 
 * @version 1.0.0
 
 * @name com.rtxtitanv.model.UserDTO
 
 * @description UserDTO
 
 * @date 2021/8/18 16:45
 
 */
 
@Accessors(chain = true)
 
@Data
 
public class UserDTO {
 
    private Long userId;
 
    private String userName;
 
    private Integer userAge;
 
    private String gender;
 
    private String email;
 
    private String birthday;
 
}

推荐阅读