블링블링 범블링

STS_pom_설정_mybatis_연동 - root-context.xml 본문

Technology/프레임워크

STS_pom_설정_mybatis_연동 - root-context.xml

뻠스키 2018. 7. 12. 14:22

root-context.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:mybatis-spring="http://mybatis.org/schema/mybatis-spring"

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

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

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

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

xsi:schemaLocation="http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring-1.2.xsd

http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd

http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd

http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd

http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd

http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.3.xsd">

<!-- 5. 스프링 빈 등록하기 위해서 추가 -->

<context:component-scan base-package="*"></context:component-scan>


<!-- 1. DataSource 설정추가하고 JUnit 연결 테스트하기 -->

<bean id="dataSource"

class="org.springframework.jdbc.datasource.DriverManagerDataSource">

<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"></property>

<property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:xe"></property>

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

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

</bean>

<!-- 2. MyBatis 연동을 위한 추가 -->

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">

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

         <!-- 3. resource에 mybatis-config.xml 만들고 추가하기 -->

         <property name="configLocation" value="classpath:mybatis-config.xml" />

<!-- 4. resource에 mappers 디렉토리를 만들고 추가하기 mybatis dqm -->

         <property name="mapperLocations" value="classpath:mappers/**/*Mapper.xml" />

     </bean>


<!-- 6. @repository 에서 의존성 주입을 위한 설정 -->

     <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate" destroy-method="clearCache">

<constructor-arg name="sqlSessionFactory" ref="sqlSessionFactory"></constructor-arg>

</bean>

    

</beans>

'Technology > 프레임워크' 카테고리의 다른 글

SPRING SAMPLE CODE  (0) 2018.07.16
spring - STS_pom_설정_mybatis_연동 - pom.xml  (0) 2018.07.12
Spring 개요  (0) 2018.07.12
Comments