전 시간에는 간단한 SQL 문 사용을 위해 Annotation을 사용하였다면,
이번에는 복잡한 쿼리를 처리할 xml 을 사용해보자 !
1) 마찬가지로 Mapper 패키지에 interface 를 추가한다

2) Resource 폴더에 폴더를 추가후 xml 을 추가하여 준다.

3) xml 작성

namespace => 해당 클래스 이름 경로 설정
select id => 해당 클래스 함수 작성
resultType => SQL문 결과를 작성
4) application.properties 파일 수정

5) service 패키지 추가후 설정

6) Controller 에서 사용해본다.

7) 확인


'Spring' 카테고리의 다른 글
| [Spring] Thymeleaf 의 th:fragment 와 replace 관계 2 (0) | 2021.10.28 |
|---|---|
| [Spring] Thymeleaf 의 th:fragment 와 replace 관계 (0) | 2021.10.28 |
| [Spring] MyBatis 1 (0) | 2021.10.26 |
| [Spring] cannot move project to target location (0) | 2021.10.13 |
| [Spring] Description:Failed to bind properties under 'server.port' to java.lang.Integer: (0) | 2021.10.13 |