mybatis¸¦ spring¿¡¼ ¼³Á¤ÇÏ´Â ¹æ¹ý
mybatis-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
<!-- //MySql -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="${db.driverClassName}"/>
<property name="url" value="${db.url}"/>
<property name="username" value="${db.username}"/>
<property name="password" value="${db.password}"/>
<property name="maxActive" value="20"/>
<property name="maxIdle" value="10"/>
<property name="validationQuery" value="select 1"/>
</bean>
<!--
#####################################################
# myBatis setting
#####################################################
-->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:com/fcm/config/mybatis/mybatis-config.xml"/>
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
</bean>
<bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg ref="sqlSessionFactory"/>
</bean>
<!-- Æ®·£Á§¼Ç »ç¿ë½Ã ÇÊ¿äÇÔ -->
<tx:annotation-driven transaction-manager="transactionManager" />
</beans>
mybatis-config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<typeAliases>
<typeAlias alias="user" type="com.fcm.object.User" />
</typeAliases>
<mappers>
<mapper resource="com/fcm/config/mybatis/common.xml"/>
<mapper resource="com/fcm/config/mybatis/event.xml"/>
<mapper resource="com/fcm/config/mybatis/template.xml"/>
<mapper resource="com/fcm/config/mybatis/user.xml"/>
<mapper resource="com/fcm/config/mybatis/channel.xml"/>
<mapper resource="com/fcm/config/mybatis/article.xml"/>
<mapper resource="com/fcm/config/mybatis/magazine.xml"/>
</mappers>
</configuration>
Ãâó: http://devx.tistory.com/entry/mybatis¸¦-spring¿¡¼-¼³Á¤ÇÏ´Â-¹æ¹ý [Meta Developer Story]