본문 바로가기

Java/spring boot with JPA

Mapper, Dependency

반응형

Maven Dependency 에 대해 작성해보겠습니다.

mvnrepository.com/

 

Maven Repository: Search/Browse/Explore

The JWebSwing implementation for Angular Pretty Checkboxes Last Release on Nov 2, 2020

mvnrepository.com

modelMapper 는

도메인 값과 DTO의 mapping을 자동으로 해주는 역할입니다. 

 

1. Mapper

mapstruct.org/

 

MapStruct – Java bean mappings, the easy way!

Java bean mappings, the easy way! Get started Download

mapstruct.org

기존에는 JPA Entity 가 될 class 와 DTO로 사용할 클래스를 따로정의하였습니다.

이 둘은 아주 비슷하며 차이점은 이름이나 type 정도일 것입니다.

Mapper Interface를 사용한다면 보다 체계적으로 java객체간에 값을 전달할 수 있습니다.

 

 

2. Dependency

Spring boot 가 관리해주는 dependency가 아닌 이상 특정 version을 명시하여 version을 묶어 주는 것이 좋습니다.

Spring boot 가 관리하는 의존성인데 버전을 바꾸고 싶은 경우에는 아래와 같이 properties 를 사용하시면 됩니다.

SpringBootApplication 을 통한 자동 설정에 대해 알아보겠습니다.

Spring Boot Application을 생성하시면 main 클래스에 @SpringBootApplication을 볼 수 있습니다.

이 어노테이션은 @Configuration, @ComponentScan, @EnableAutoConfiguration 을 설정한 부분으로 볼 수 있습니다.

 

@ComponentScan, @EnableAutoConfiguration 은 Bean을 읽는 역할을 수행합니다. @ComponentScan이 먼저 일어나고 그 뒤 @EnableAutoConfiguration이 일어납니다.

 

@ComponentScan은 @Component , @Configuration, @Repository, @Service, @Controller, @RestController 를 가진 class를 스캔하여 Bean으로 등록합니다.

@EnableAutoConfiguration은 Convention들을 Bean으로 등록합니다. ServletWebServerFactory Bean을 만드는 역할도 수행합니다. 이를 통해 webapplcaiton을 띄울 수 있습니다.

반응형

'Java > spring boot with JPA' 카테고리의 다른 글

CORS  (0) 2020.12.26
Optional  (0) 2020.12.01
Spring boot  (0) 2020.10.30
spring boot & JPA 프로젝트 생성 (JDBC는?)  (0) 2020.07.28
AWS 에 Spring boot project 배포하기  (0) 2020.07.21