728x90
반응형
마이바티스에서 멀티 db 설정하기 위해서 2개의 db 설정 파일입니다.
데이터베이스트 티베로와 postgresq입니다. 티베로 db를 사용하기 위해서 tibero mapper 클래스를 만들어서 설정을 하였습니다.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd">
<!-- 실행환경에서 빈이름 참조(EgovAbstractDAO) -->
<bean id="egov.lobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler" lazy-init="true" />
<!-- postgresql db -->
<bean id="egov.sqlSession" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="egov.postgreDataSource"/>
<property name="configLocation" value="classpath:/egovframework/sqlmap/mapper/postgre/config/mapper-config.xml" />
<property name="mapperLocations">
<list>
<value>classpath:/egovframework/sqlmap/mapper/postgre/invako/**/*.xml</value>
</list>
</property>
</bean>
<!-- Mybatis Session Template -->
<bean id="egov.sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg ref="egov.sqlSession"/>
</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.invako.**.mybatis.mapper" />
<property name="sqlSessionFactoryBeanName" value="egov.sqlSession"/>
</bean>
<alias name="egov.sqlSession" alias="sqlSession" />
<!-- tibero db -->
<bean id="sqlSessionTibero" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="egov.tiberoDataSource"/>
<property name="configLocation" value="classpath:/egovframework/sqlmap/mapper/postgre/config/mapper-config.xml" />
<property name="mapperLocations">
<list>
<value>classpath:/egovframework/sqlmap/mapper/tibero/invako/**/*.xml</value>
</list>
</property>
</bean>
<!-- Tibero Mapper Interface -->
<bean class="egovframework.rte.psl.dataaccess.mapper.MapperConfigurer">
<property name="basePackage" value="egovframework.invako.**.mybatisTibero.mapper" />
<property name="sqlSessionFactoryBeanName" value="sqlSessionTibero"/>
<property name="annotationClass" value="egovframework.invako.util.TiberoMapper"/>
</bean>
</beans>
728x90
반응형
'프로그램 > JPA' 카테고리의 다른 글
context-transaction.xml (0) | 2021.07.02 |
---|---|
context-nexacro.xml (0) | 2021.07.02 |
context-jpa-repository.xml (0) | 2021.07.02 |
context-hibernate.xml (0) | 2021.07.02 |
context-datasource.xml 설정 파일 (0) | 2021.07.02 |
댓글