본문 바로가기

웹개발 셋팅

root-context.xml (applicationContext.xml)

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:aop="http:www.springframework.org/schema/aop"

xmlns:tx="http://www.springframework.org/schema/tx"

xmlns:context="http://www.springframwork.org/schema/p"

xmlns:p="http://www.springframwork.org/schema/p"

xmlns:jdbc="http://www.springframwork.org/schema/jdbc"

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd

http://www.springframework.org/schema/aop http://www.springframwork.org/schema/context/spring-aop-3.2.xsd

http://www.springframework.org/schema/tx http://www.springframwork.org/schema/context/spring-tx-3.2.xsd

http://www.springframework.org/schema/context http://www.springframwork.org/schema/context/spring-context-3.2.xsd">

<!-- Root Context: defines shared resources visible to all other web components -->

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">

<property name="driverClassName" value="net.sf.log4jdbc.DriverSpy"/>

<property name="url" value="jdbc:log4jdbc:oracle:thin:@localhost:1521:ORCL"/>

<property name="username" value="name"/>

<property name="password" value="pwd"/>

<property name="maxActive" value="10"/>

<property name="maxIdle" value="3"/>

<property name="maxWait" value="10000"/>

<property name="defaultAutoCommit" value="true"/>

<property name="validationQuery" value="select 1 from dual"/>

</bean>

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean" lazy-init="true">

<property name="dataSource" ref="dataSource"/>

<property name="configLocation" value="/WEB-INF/mybatis/mybatis-config.xml"/>    <!-- 설정파일경로-->

</bean>

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

<constructor-arg index="0" ref="sqlSessionFactory"/>

</bean>

<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">

<property name="dataSource" ref="dataSource"/>

</bean>

<bean id="transactionTemplate" class="org.springframework.transaction.support.TransactionTemplate">

<property name="transactionManager" ref="transactionManager"></property>

</bean>

</beans>



위와 같이 해주면 된다.

신경쓰자면 마이바티스 맵퍼를 config파일에서 처리하지 않고 여기서 하려면 name을 mapperLocations 라 명명하고 value에 경로를 지정하고 *.xml을 설정해주면 된다. 아래 참고 하시라..

  <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean" lazy-init="true">

<property name="dataSource" ref="dataSource"/>

<property name="configLocation" value="/WEB-INF/mybatis/mybatis-config.xml"/>

<property name="mapperLocations" value="/WEB-INF/mybatis/mapper/*.xml"/>

</bean>



'웹개발 셋팅' 카테고리의 다른 글

dispatcher-servlet.xml  (0) 2013.11.27
security-context.xml  (0) 2013.11.27
web.xml  (0) 2013.11.27
VPN이란  (0) 2013.11.27
이클립스에서 DB2 log4jdbc 사용하기  (0) 2013.11.25