개발 소발/개발 Spring

Mybatis 셋팅이란?

우기! 2017. 12. 21. 10:47

Mybatis 셋팅이란?


pom.xml에 추가한다.



1.설정해줘야한다. SqlSessionFactoryBean 

SqlSessionFactoryBean 

-DataSource(데이터베이스 커넥션)

-MyBatisConfig File(Mybatis 파일 위치정보)

(sqlMapConfig.xml)

-mapping File(쿼리SQL문을 포함)

(user.xml)



2.컴포넌트생성

(Mybatis제공 컴포넌트)

SqlSessionFactory 생성방법.




<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">

<constructor-arg ref="sqlSessionFactory" />

</bean>



3.SqlSessionFactory정보를 전달

SqlSessionTemplate(인터페이스 구현)


4.이 인터페이스를 구현한게 SqlSessionTemplate이다.

(Mybatis제공)

SqlSession(인터페이스)



SqlMapConfig.xml

vo클래스명 정리해준다.


User.xml

쿼리 포함된 mapping파일

namespace 이름 설정해준다.