공부하면서/spring boot

[Spring Boot / JPA] DTO / entity 형변환 ModelMapper

코린영이 2024. 2. 8. 16:33
728x90
반응형

 

목차

1. DTO <-> Entity 변환

3. 참고사이트

 

 

1. ModelMapper

 dependency 추가 

gradle

implementation group: 'org.modelmapper', name: 'modelmapper', version: '2.3.8'

 

maven

<dependency>
    <groupId>org.modelmapper</groupId>
    <artifactId>modelmapper</artifactId>
    <version>2.3.8</version>
</dependency>

 

사용 방법

ModelMapper model = new ModelMapper();

Employee employee = model.map(employeeDto, Employee.class);

 

 

참고사이트

https://squirmm.tistory.com/entry/Spring-modelMapper

 

[Spring/Java] modelMapper

1. modelMapper 란? "서로 다른 클래스의 값을 한 번에 복사하게 도와주는 라이브러리" 어떤 Object(Source Object)에 있는 필드 값들을 자동으로 원하는 Object(Destination Object)에 Mapping 시켜주는 라이브러리

squirmm.tistory.com

https://mapstruct.org/documentation/stable/reference/html/#mapping-with-builders

 

MapStruct 1.5.5.Final Reference Guide

If set to true, MapStruct in which MapStruct logs its major decisions. Note, at the moment of writing in Maven, also showWarnings needs to be added due to a problem in the maven-compiler-plugin configuration.

mapstruct.org

https://ykh6242.tistory.com/entry/%EB%B0%98%EB%B3%B5%EC%A0%81%EC%9D%B8-DTO-%EB%B3%80%ED%99%98-%EC%9E%91%EC%97%85%EC%9D%84-%ED%95%9C-%EB%B2%88%EC%97%90-%EC%A0%95%EC%9D%98-MapStruct-%EA%B8%B0%EB%B3%B8-%EC%A0%95%EB%A6%AC

 

반복적인 DTO 변환 작업을 한 번에 정의! MapStruct 기본 정리

MapStruct 1.4.2.Final Reference Guide를 기준으로 작성되었습니다. Introduction MapStruct는 객체의 타입 변환 시에 유용하게 사용할 수 있는 라이브러리이다. 어노테이션 기반으로 작성되며 Bean으로 등록할

ykh6242.tistory.com

 

728x90
반응형