프로젝트 정리/스프링과 JPA 기반 웹 애플리케이션 개발
31. ModelMapper 적용
JunGi Jeong
2021. 12. 28. 23:38
- 객체의 프로퍼티를 다른 객체의 프로퍼티로 맵핑해주는 유틸리티
의존성 추가
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<!-- <version>2.3.6</version> -->
<!-- 라이브러리 다운로드가 불가하여 2.4.2 버전사용 -->
<version>2.4.2</version>
</dependency>
토크나이저 설정
modelMapper.getConfiguration()
.setSourceNameTokenizer(NameTokenizers.UNDERSCORE)
.setDestinationNameTokenizer(NameTokenizers.UNDERSCORE)
- UNDERSCORE(_)를 사용했을 때에만 nested 객체를 참조하는 것으로 간주하고 그렇지 않은 경우에는 해당 객체의 직속 프로퍼티에 바인딩 한다.
- http://modelmapper.org/user-manual/configuration/#matching-strategies
실습
- 시작 커밋: https://github.com/devjun63/whiteship-studyolle/commit/5dfd08c07eb67a1ceed6d8a1e4ddc2a6fc5469a5
- 완료 커밋:https://github.com/devjun63/whiteship-studyolle/commit/b11153692623259ba7a36194c32fd8df9a15b297
30. 알림 설정 · devjun63/whiteship-studyolle@5dfd08c
Permalink This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. Browse files 30. 알림 설정 Loading branch information Showing 5 changed files with 143 additions and 4 deletions. +11 −0 src/m
github.com
31. ModelMapper 적용 · devjun63/whiteship-studyolle@b111536
Permalink This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. Browse files 31. ModelMapper 적용 Loading branch information Showing 6 changed files with 36 additions and 38 deletions. +5 −0 p
github.com