database.xml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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"
  4. xsi:schemaLocation="http://www.springframework.org/schema/beans
  5. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
  6. <bean id="dataSource" name="dataSource" destroy-method="close" init-method="init" class="com.alibaba.druid.pool.DruidDataSource"
  7. scope="singleton">
  8. <!-- <property name="driverClassName" value="${dataSource.driverClassName}" />
  9. <property name="url" value="${dataSource.url}" />
  10. <property name="username" value="${dataSource.username}"/>
  11. <property name="password" value="${dataSource.password}"/>
  12. <property name="validationQuery" value="SELECT 1 from dual"/>
  13. <property name="testOnBorrow" value="true"/>
  14. <property name="testWhileIdle" value ="true"/>
  15. <property name="timeBetweenEvictionRunsMillis" value="30000" />
  16. <property name="numTestsPerEvictionRun" value="20" />
  17. <property name="initialSize" value="10"/>
  18. <property name="maxActive" value="20"/>
  19. <property name="maxIdle" value="0"/>
  20. <property name="maxWait" value="60000"/>
  21. <property name="minEvictableIdleTimeMillis" value="3600000"/> -->
  22. <property name="url" value="${dataSource.url}"/>
  23. <property name="username" value="${dataSource.username}"/>
  24. <property name="password" value="${dataSource.password}"/>
  25. <!-- 初始化连接大小 -->
  26. <property name="initialSize" value="0"/>
  27. <!-- 连接池最大使用连接数量 -->
  28. <property name="maxActive" value="20"/>
  29. <!-- 连接池最小空闲 -->
  30. <property name="minIdle" value="0"/>
  31. <!-- 获取连接最大等待时间 -->
  32. <property name="maxWait" value="60000"/>
  33. <property name="poolPreparedStatements" value="true"/>
  34. <property name="maxPoolPreparedStatementPerConnectionSize" value="33"/>
  35. <!-- 用来检测有效sql -->
  36. <property name="validationQuery" value="SELECT 1 from dual"/>
  37. <property name="testOnBorrow" value="false"/>
  38. <property name="testOnReturn" value="false"/>
  39. <property name="testWhileIdle" value="true"/>
  40. <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
  41. <property name="timeBetweenEvictionRunsMillis" value="60000"/>
  42. <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
  43. <property name="minEvictableIdleTimeMillis" value="25200000"/>
  44. <!-- 打开removeAbandoned功能 -->
  45. <property name="removeAbandoned" value="true"/>
  46. <!-- 1800秒,也就是30分钟 -->
  47. <property name="removeAbandonedTimeout" value="1800"/>
  48. <!-- 关闭abanded连接时输出错误日志 -->
  49. <property name="logAbandoned" value="true"/>
  50. <!-- 监控数据库 -->
  51. <property name="filters" value="stat"/>
  52. </bean>
  53. <!-- <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"
  54. scope="singleton" lazy-init="true">
  55. <property name="configLocation"
  56. value="classpath:com/startup/minpay/frame/jdbc/mybatisConfigure.xml"></property>
  57. <property name="dataSource" ref="dataSource" />
  58. <property name="mapperLocations">
  59. <list>
  60. <value>classpath:com/minpay/db/table/mapper/*.xml</value>
  61. <value>classpath:com/minpay/db/table/own/mapper/*.xml</value>
  62. </list>
  63. </property>
  64. <property name="typeAliasesPackage" value="com.minpay.db" />
  65. </bean> -->
  66. <bean id="sqlSessionFactory" class="com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean">
  67. <property name="configLocation"
  68. value="WEB-INF/mybatisConfigure.xml"></property>
  69. <property name="dataSource" ref="dataSource"/>
  70. <property name="mapperLocations">
  71. <list>
  72. <value>classpath:com/minpay/db/table/mapper/*.xml</value>
  73. <value>classpath:com/minpay/db/table/own/mapper/*.xml</value>
  74. </list>
  75. </property>
  76. <property name="typeAliasesPackage" value="com.minpay.db" />
  77. </bean>
  78. <!-- <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"
  79. scope="singleton" lazy-init="true">
  80. <property name="basePackage" value="com.min.xxpro.db" />
  81. </bean> -->
  82. <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
  83. <property name="basePackage" value="com.minpay.db.table.mapper"/>
  84. </bean>
  85. <bean id="transactionFactory"
  86. class="org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory"
  87. scope="singleton" lazy-init="true"/>
  88. <bean id="databaseManager" class="com.startup.minpay.frame.jdbc.MINDataBaseManager"
  89. scope="singleton">
  90. <constructor-arg>
  91. <ref bean="sqlSessionFactory" />
  92. </constructor-arg>
  93. <constructor-arg>
  94. <ref bean="transactionFactory" />
  95. </constructor-arg>
  96. </bean>
  97. </beans>