- dbconfig.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:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring.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.xsd">
<context:annotation-config />
<bean id="dbInfo" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.cj.jdbc.Driver"></property>
<property name="url" value="jdbc:mysql://localhost:3306/cms"></property>
<property name="username" value="hana"></property>
<property name="password" value="hana1234"></property>
</bean>
<!-- 1 -->
<bean id="sqlfact" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dbInfo"></property>
<property name="configLocation" value="classpath:/META-INF/config.xml"></property>
<property name="mapperLocations" value="classpath:/META-INF/mapper.xml"></property>
</bean>
<bean id="template" class="org.mybatis.spring.SqlSessionTemplate" destroy-method="close">
<constructor-arg name="sqlSessionFactory" ref="sqlfact"></constructor-arg>
</bean>
<!-- 2. 기존거에서 걍 이렇게 추가하면 됨 -->
<bean id="sqlfact2" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dbInfo"></property>
<property name="configLocation" value="classpath:/META-INF/config2.xml"></property>
<property name="mapperLocations" value="classpath:/META-INF/mapper2.xml"></property>
</bean>
<bean id="template2" class="org.mybatis.spring.SqlSessionTemplate" destroy-method="close">
<constructor-arg name="sqlSessionFactory" ref="sqlfact2"></constructor-arg>
</bean>
</beans>
🔽
mapper2.xml , config2.xml 새로 생성
'CLASS > SPRING,JSTL' 카테고리의 다른 글
☀ mybatis - mapper ☀ (0) | 2024.07.25 |
---|---|
#9-2 / notice list + category 검색기능( 동적 query문 ), delete (1) | 2024.07.24 |
#9-1 / ☔ - 통계차트 수정,삭제 페이지 (0) | 2024.07.24 |
#8-3 / ☔ - 통계차트 출력 페이지(list) , ajax(SPA)+do (0) | 2024.07.23 |
#8-2 /☔ 통계 data 관련 project 만들기 - selectOne(ajax),insert (0) | 2024.07.23 |