Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- spring mapper annotation
- JAVA Exception 종류
- doker logs tail
- Vue
- CrudRepository update
- Spring
- 도커 컨테이너 로그
- mapper annotationo
- JPA DB 다중 Connection
- Spring JPA Specification
- spring JPA DB Connection
- spring mapper
- Data Annotation
- spring @mapper
- JPA DB Connection 다중
- spring repository
- vueslot
- NoArgsConstructor
- vuecomponent
- docker 로그
- spring JPA DB multi Connection
- @Builder @NoArgsConstructor
- JpaRepository update
- AllArgsConstructor
- 자바버그수정
- spring DB Connection
- Transactions Propagation Option
- 도커 logs
- 도커 로그 확인
- repository annotation
Archives
- Today
- Total
개발을 잘하고 싶은 개발자
[Spring] @Mapper 너는 누구니? 본문
xml 기반의 mapper를 사용할 때
<mapper namespace="com.kr.mapper.Test">
<select id="getTest" parameterType="java.util.HashMap" resultType="java.util.HashMap">
/* query */
</select>
</mapper>
이런 식으로 mapper 태그 안에 쿼리를 넣어 사용한다
But, 방식으로 DB의 데이터를 객체로 매핑시켜 데이터를 접근하는 ORM 방식을 사용해보면서
@Mapper를 사용하게 되었다
https://codingnojam.tistory.com/27
여기 블로그에 아주 잘 설명을 해주셨고 많은 도움이 되어 참고를 해본다
https://mybatis.org/mybatis-3/ko/apidocs/index.html
@Mapper의 API 문서를 찾아보니
Maker interface for MyBatis mappers 라고 한다 => "MyBatis 매퍼용 메이커 인터페이스"
그럼 MyBatis 문서에서 확인해 본다
https://mybatis.org/spring/ko/mappers.html#register
@MapperScan을 사용하면 하나씩 매퍼를 등록할 필요가 없다고 한다
자동 스캔 기능으로
@MapperScan(
basePackages = {"com.test.api.mappers"}
)
이렇게 사용해 주면 mappers 디렉토리 안에 있는 인터페이스에는 자동 컴포넌트 지정이 된다
이 외의 특정 인터페이스를 매퍼로 등록하고 싶을 때 @Mapper를 사용한다

'Backend > spring' 카테고리의 다른 글
[Spring] Transactions Propagation Option with Spring JPA (0) | 2021.08.18 |
---|---|
[Spring] @Repository는 언제 쓰나요? (0) | 2021.08.07 |
[Spring] JPA DB Connection 다중으로 사용하기! (0) | 2021.08.03 |
[Spring JPA] JpaRepository update업데이트 하고 싶지만 save (0) | 2021.08.02 |
[Spring] RESTful 서비스 설계 - Exception 설계한 Response 처리 (0) | 2021.07.24 |