码迷,mamicode.com
首页 > 其他好文 > 详细

多数据源配置

时间:2015-11-25 11:42:44      阅读:117      评论:0      收藏:0      [点我收藏+]

标签:

数据源1

<bean id="dataSource1" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">

...

</bean>

 

<bean id="transactionManager1"

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

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

</bean>

 

         <!-- 使用annotation定义事务 -->

   <tx:annotation-driven transaction-manager="transactionManager1" proxy-target-class="true" />

        

 <bean id="jdbcTemplate1" class="org.springframework.jdbc.core.JdbcTemplate">

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

</bean>

<bean id="commonDao1" class="com.zw.common.CommonDao">

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

</bean>

<bean id="commonService1" class="com.zw.common.CommonService">

         <property name=" commonDao" ref=" commonDao1" />

</bean>

 

数据源2

<bean id="dataSource2" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">

...

</bean>

 

<bean id="transactionManager2"

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

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

</bean>

 

         <!-- 使用annotation定义事务 -->

   <tx:annotation-driven transaction-manager="transactionManager2" proxy-target-class="true" />

        

 <bean id="jdbcTemplate2" class="org.springframework.jdbc.core.JdbcTemplate">

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

</bean>

<bean id="commonDao2" class="com.zw.common.CommonDao">

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

</bean>

<bean id="commonService2" class="com.zw.common.CommonService">

         <property name=" commonDao" ref=" commonDao2" />

</bean>

多数据源配置

标签:

原文地址:http://www.cnblogs.com/hdsbk/p/4994030.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!