Instantly share code, notes, and snippets.

Embed
What would you like to do?
여러 개의 DataSource를 Access하는 Spring ApplicationContext 설정
<!– Oracle DB Data Source–>
<bean id=”primaryDataSource” class=”org.apache.commons.dbcp.BasicDataSource”
destroy-method=”close” p:driverClassName=”${primaryora.jdbc.driverClassName}”
p:url=”${primaryora.jdbc.url}” p:username=”${primaryora.jdbc.username}”
p:password=”${primaryora.jdbc.password}” p:maxActive=”${primaryora.jdbc.maxActive}” />
<bean id=”standbyDataSource” class=”org.apache.commons.dbcp.BasicDataSource”
destroy-method=”close” p:driverClassName=”${standbyora.jdbc.driverClassName}”
p:url=”${standbyora.jdbc.url}” p:username=”${standbyora.jdbc.username}”
p:password=”${standbyora.jdbc.password}” p:maxActive=”${standbyora.jdbc.maxActive}” />
<!– MySQL Review Data Source –>
<bean id=”distReadDataSource” class=”org.apache.commons.dbcp.BasicDataSource”
destroy-method=”close” p:driverClassName=”${dist.read.jdbc.driverClassName}”
p:url=”${dist.read.jdbc.url}” p:username=”${dist.read.jdbc.username}”
p:password=”${dist.read.jdbc.password}” p:maxActive=”${dist.read.jdbc.maxActive}” />
<bean id=”distWriteDataSource” class=”org.apache.commons.dbcp.BasicDataSource”
destroy-method=”close” p:driverClassName=”${dist.write.jdbc.driverClassName}”
p:url=”${dist.write.jdbc.url}” p:username=”${dist.write.jdbc.username}”
p:password=”${dist.write.jdbc.password}” p:maxActive=”${dist.write.jdbc.maxActive}” />
<!– Transaction Manager –>
<bean id=”transactionManager”
class=”org.springframework.jdbc.datasource.DataSourceTransactionManager”>
<property name=”dataSource” ref=”dataSource” />
</bean>
<!– define the SqlSessionFactory –>
<bean id=”sqlSessionFactory” class=”org.mybatis.spring.SqlSessionFactoryBean”>
<property name=”dataSource” ref=”dataSource” />
<property name=”typeAliasesPackage” value=”kr.sidnancy.entity” />
</bean>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment