[ Info Spring ] Mybatis 란??
💎 Mybatis 란??
- 데이터의 입력, 조회, 수정, 삭제(CRUD)를 보다 편하게 하기 위해 xml로 구조화한 Mapper 설정 파일을 통해서 JDBC를 구현한 영속성 프레임워크
- 기존에 JDBC를 통해 구현했던 상당 부분의 코드와 파라미터 설정 및 결과 매핑을 xml 설정을 통해 쉽게 구현할 수 있게 해준다
📣 Mybatis API 사이트
http://www.mybatis.org/mybatis-3/ko
📣 Mybatis 흐름
- 이전에 JDBC Template을 통해 SQL을 실행하였다면 Mybatis는 해당 흐름을 전용 라이브러리를 통해 대체하여 동작한다고 생각하면 된다.
📣 JDBC, Spring, Mybatis 관련 모듈,라이브러리 추가
JDBC 드라이버 (ojdbc11) : https://mvnrepository.com/artifact/com.oracle.database.jdbc/ojdbc11
Spring에서 JDBC지원하는 모듈 (spring-jdbc) : https://mvnrepository.com/artifact/org.springframework/spring-jdbc
Mybatis 라이브러리 (mybatis) : https://mvnrepository.com/artifact/org.mybatis/mybatis
Spring에서 쉽게 Mybatis를 사용 가능하게 만드는 모듈 : https://mvnrepository.com/artifact/org.mybatis/mybatis-spring
DataBase Connection Pool 사용을 위한 라이브러리 : https://mvnrepository.com/artifact/org.apache.commons/commons-dbcp2
💎 설정
[ Setting Spring mybatis ] mybatis-config 설정
💎 Mybatis 동작 구조 💎 mybatis-config 설정 ◈ Mybatis 설정용 XML 파일 DTD( Document Type Definiton ) 추가 Window - Preferences - XML - XML Catalog - User Specified Entries 클릭 - Config Location : http://mybatis.org/dtd/mybatis-3-confi
mungwang.tistory.com
[ Spring, JDBC, Mybatis ] 관련 설정하기(root-context.xml)
💎 root-context.xml 설정 추가 📣 DBCP(커넥션풀) 설정 추가 📣 SqlSession 관련 설정 및 트랜잭션 제어 설정 추가 📣 Mybatis 내장 별칭
mungwang.tistory.com
[ Setting Spring mapper ] mapper 설정
💎 mapper.xml 생성 위치 - ‘src/main/resources’폴더에 ‘mappers’ 폴더 생성 후 mapper.xml 파일 생성 💎 mapper.xml 작성
mungwang.tistory.com