appContext.xml 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
  4. xmlns:aop="http://www.springframework.org/schema/aop"
  5. xmlns:context="http://www.springframework.org/schema/context"
  6. xsi:schemaLocation="
  7. http://www.springframework.org/schema/beans
  8. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd ">
  9. <bean id="dataSource"
  10. class="cn.sinobest.framework.comm.transcation.AppRoutingDataSource">
  11. <property name="targetDataSources">
  12. <map key-type="java.lang.String">
  13. <entry key="ds" value-ref="dataSource1" /> <!-- 数据源1 -->
  14. <entry key="ds2" value-ref="dataSource2" /><!-- 数据源2 -->
  15. </map>
  16. </property>
  17. <property name="defaultTargetDataSource" ref="dataSource1" /> <!-- 默认数据源为datasource1 -->
  18. </bean>
  19. <!-- datasource配置2 注:测试使用 -->
  20. <bean id="dataSource1" class="org.apache.commons.dbcp.BasicDataSource"
  21. destroy-method="close">
  22. <property name="driverClassName">
  23. <value>${jdbc.driver}</value>
  24. </property>
  25. <property name="url">
  26. <value>${jdbc.url}</value>
  27. </property>
  28. <property name="username">
  29. <value>${jdbc.username}</value>
  30. </property>
  31. <property name="password">
  32. <value>${jdbc.password}</value>
  33. </property>
  34. <property name="minIdle">
  35. <value>${jdbc.minIdle}</value>
  36. </property>
  37. <property name="maxActive" >
  38. <value>${jdbc.maxActive}</value>
  39. </property>
  40. <property name="maxIdle">
  41. <value>${jdbc.maxIdle}</value>
  42. </property>
  43. <property name="initialSize">
  44. <value>${jdbc.initialSize}</value>
  45. </property>
  46. <property name="validationQuery" >
  47. <value>${jdbc.validationQuery}</value>
  48. </property>
  49. </bean>
  50. <!-- datasource配置2 注:测试使用 -->
  51. <bean id="dataSource2" class="org.apache.commons.dbcp.BasicDataSource"
  52. destroy-method="close">
  53. <property name="driverClassName">
  54. <value>${jdbc.driver2}</value>
  55. </property>
  56. <property name="url">
  57. <value>${jdbc.url2}</value>
  58. </property>
  59. <property name="username">
  60. <value>${jdbc.username2}</value>
  61. </property>
  62. <property name="password">
  63. <value>${jdbc.password2}</value>
  64. </property>
  65. <property name="minIdle">
  66. <value>${jdbc.minIdle2}</value>
  67. </property>
  68. <property name="maxActive" >
  69. <value>${jdbc.maxActive2}</value>
  70. </property>
  71. <property name="maxIdle">
  72. <value>${jdbc.maxIdle2}</value>
  73. </property>
  74. <property name="initialSize">
  75. <value>${jdbc.initialSize2}</value>
  76. </property>
  77. <property name="validationQuery" >
  78. <value>${jdbc.validationQuery2}</value>
  79. </property>
  80. </bean>
  81. </beans>