rtrh-datasource.xml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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:aop="http://www.springframework.org/schema/aop"
  4. xmlns:tx="http://www.springframework.org/schema/tx"
  5. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  6. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
  7. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
  8. <!--数据库管理-连接信息的配置文件加载 -->
  9. <bean id="propertyConfig"
  10. class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  11. <property name="location" value="classpath:/dbconfig.properties" />
  12. </bean>
  13. <!-- <bean id="bonecpConfig"
  14. class="org.springframework.beans.factory.config.PropertiesFactoryBean">
  15. <property name="location" value="classpath:/bonecpconfig.properties" />
  16. </bean>
  17. 数据库管理-数据源3定义(BoneCP连接池)
  18. <bean id="poolDataSource" class="com.jolbox.bonecp.BoneCPDataSource" >
  19. <property name="driverClass" value="${jdbc.driver}" />
  20. <property name="jdbcUrl" value="${jdbc.url}" />
  21. <property name="username" value="${jdbc.username}" />
  22. <property name="password" value="${jdbc.password}" />
  23. <property name="properties" ref="bonecpConfig"></property>
  24. </bean> -->
  25. <bean id="poolDataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
  26. <property name="url" value="${jdbc.url}" />
  27. <property name="username" value="${jdbc.username}" />
  28. <property name="password" value="${jdbc.password}" />
  29. <property name="driverClassName" value="${jdbc.driver}" />
  30. <property name="filters" value="stat" />
  31. <property name="maxActive" value="100" />
  32. <property name="initialSize" value="1" />
  33. <property name="maxWait" value="60000" />
  34. <property name="timeBetweenEvictionRunsMillis" value="60000" />
  35. <property name="minEvictableIdleTimeMillis" value="300000" />
  36. <property name="validationQuery" value="SELECT 'x' FROM DUAL" />
  37. <property name="testWhileIdle" value="true" />
  38. <property name="testOnBorrow" value="false" />
  39. <property name="testOnReturn" value="false" />
  40. <property name="maxOpenPreparedStatements" value="100" />
  41. </bean>
  42. <bean id="secondaryDataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
  43. <property name="url" value="${jdbc.secondary.url}" />
  44. <property name="username" value="${jdbc.secondary.username}" />
  45. <property name="password" value="${jdbc.secondary.password}" />
  46. <property name="driverClassName" value="${jdbc.secondary.driver}" />
  47. <property name="filters" value="stat" />
  48. <property name="maxActive" value="100" />
  49. <property name="initialSize" value="1" />
  50. <property name="maxWait" value="60000" />
  51. <property name="timeBetweenEvictionRunsMillis" value="60000" />
  52. <property name="minEvictableIdleTimeMillis" value="300000" />
  53. <property name="validationQuery" value="SELECT 'x' FROM DUAL" />
  54. <property name="testWhileIdle" value="true" />
  55. <property name="testOnBorrow" value="false" />
  56. <property name="testOnReturn" value="false" />
  57. <property name="maxOpenPreparedStatements" value="100" />
  58. </bean>
  59. <bean id="dataSource" class="com.rtrh.projects.web.util.DynamicDataSource">
  60. <property name="targetDataSources">
  61. <map>
  62. <entry key="primary" value-ref="poolDataSource" />
  63. <entry key="secondary" value-ref="secondaryDataSource" />
  64. </map>
  65. </property>
  66. <property name="defaultTargetDataSource" ref="poolDataSource" />
  67. </bean>
  68. </beans>