728x90
multi DB ์ฐ๊ฒฐํ๋๊ฒ ์ด๋ ต์ง ์์ง๋ง
๋์ฒ๋ผ ์ด์ฒ๊ตฌ๋ ์๋ ์ด์ ๋ก
์ค๋ ์ก๊ณ ์์ ์๋.. หฬฃฬฃฬฃฬฃฬฃฬฃ๏ธฟหฬฃฬฃฬฃฬฃฬฃฬฃ
๋์์ด ๋๊ธธ ๋ฐ๋ผ๋ฉฐ ์ ๋ ๊ธ
1. context-datasouse.xml ์ค์ ํ๊ธฐ
tibero db๋ฅผ ์ฐ๋ ํ๋ก์ ํธ์
mssql db๋ฅผ ๋ฉํฐ๋ก
ํจ๊ป ์ฌ์ฉํด์ผํด์
mssql bean์
context-datasourse.xml์ ์ถ๊ฐํด์ฃผ๊ธฐ
<!-- MSSQL -->
<bean id="dataSource-mssql" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver"/>
<property name="url" value="jdbc:sqlserver:// server์ ๋ณด :1433;DataBaseName=๋๋น๋ช
"/>
<property name="username" value="sa"/>
<property name="password" value="๋น๋ฐ๋ฒํธ"/>
</bean>
2. context-mapper.xml ์ค์ ํ๊ธฐ
์ฌ๊ธฐ์ ์ค์ํ๊ฒ
<!-- SqlSession setup for MyBatis Database Layer -->
<bean id="sqlSession" class="egovframework.ccms.cmmn.RefreshableSqlSessionFactoryBean">
<property name="dataSource" ref="dataSource-${Globals.DbType}" />
<property name="configLocation" value="classpath:/egovframework/sqlmap/ccms/sql-mapper-config.xml" />
<property name="mapperLocations" value="classpath:/egovframework/sqlmap/ccms/mappers/*.xml" />
<property name="interval" value="1000" />
<property name="databaseIdProvider" ref="databaseIdProvidor"></property>
</bean>
<!-- MapperConfigurer setup for MyBatis Database Layer with @Mapper("deptMapper") in DeptMapper Interface -->
<bean class="egovframework.rte.psl.dataaccess.mapper.MapperConfigurer">
<property name="basePackage" value="egovframework.ccms.*.mapper" />
<property name="sqlSessionFactoryBeanName" value="sqlSession" />
</bean>
package๋ช ์์ mapper ํด๋๋ช ์ด ๊ฒน์น๋ฉด ์๋๋๋ฐ
๋๋ ํด๋๋ช ์ mapper๋ก ๋์ผํ๊ฒ ์ฃผ๊ณ
.xml ํ์ผ๋ช ์ด๋ฆ๋ง ๋ค๋ฅด๊ฒ ์ค;;;
๊ทธ๋๋๊ณ ์ฐ๊ฒฐ๋๊ธธ ๋ฐ๋ฌ๋ค. . ๋ ์ ์ค ์
<!-- MSSQL -->
<!-- SqlSession setup for MyBatis Database Layer -->
<bean id="sqlSessionMssql" class="egovframework.ccms.cmmn.RefreshableSqlSessionFactoryBean">
<property name="dataSource" ref="dataSource-mssql"/>
<property name="configLocation" value="classpath:/egovframework/sqlmap/ccms/sql-mapper-config.xml" />
<property name="mapperLocations" value="classpath:/egovframework/sqlmap/ccms/mssql/mappers/*.xml" />
<property name="interval" value="1000" />
<property name="databaseIdProvider" ref="databaseIdProvidor"></property>
</bean>
<!-- MapperConfigurer setup for MyBatis Database Layer with @Mapper("deptMapper") in DeptMapper Interface -->
<bean class="egovframework.rte.psl.dataaccess.mapper.MapperConfigurer">
<property name="basePackage" value="egovframework.ccms.*.mapper2" />
<property name="sqlSessionFactoryBeanName" value="sqlSessionMssql" />
</bean>
3. package ๋ง๋ค์ด์ ํ ์คํธ
tibero DB / ์๋ ํด๋ mapper
mssql DB
context-mapper.xml ์ค์ ๋๋ก
ํด๋๋ช mapper2๋ก ๋ณ๊ฒฝ
-
๊ทธ๋ฆฌ๊ณ
jspํ๋ฉด
๋ง๋ค์ด ํ ์คํธํ๋ฉด ๋ !
'multi' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[MyBatis] CamelCase ์นด๋ฉ์ผ์ด์ค (0) | 2020.11.19 |
---|---|
[Eclipse] ์ดํด๋ฆฝ์ค ๋ ์ด์์ ์ด๊ธฐํ (2) | 2020.09.21 |
[webapp] webapp WEB-INF lib (0) | 2020.09.16 |
[MAVEN] maven repository ์ธ๋ถ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ถ๊ฐํ๊ธฐ (2) | 2020.09.16 |
[JSP] WEB-INF/ lib .jar ์ถ๊ฐ (= jsp์์ import๊ฐ ์๋ ๋) (0) | 2020.09.14 |