180418 Spring myBatis - RYUDONGJIN/Memo_wiki GitHub Wiki

servlet-context.xml myBatis 설정

<beans:bean name="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
   <beans:property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
   <beans:property name="url" value="jdbc:oracle:thin@localhost:1521:xe" />
   <beans:property name="username" value="scott" />
   <beans:property name="password" value="tiger" />
</beans:bean>

<beans:bean name="template" class="org.springframework.jdbc.core.JdbcTemplate">
   <beans:property name="dataSource" ref="dataSource" />
</beans:bean>

<beans:bean name="dao" class="com.javalec.spring.mybatis.dao.ContentDao">
   <beans:property name="template" ref="template" />
</beans:bean>

<beans:bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
   <beans:property name="dataSource" ref="dataSource" />
   <beans:property name="mapperLocations" value="classpath:com/javalec/spring_mybatis/dao/mapper/*.xml" />
</beans:bean>

<beans:bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
   <beans:constructor-arg index="0" ref="sqlSessionFactory" />
</beans:bean>