spring-mybatis.xml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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:p="http://www.springframework.org/schema/p"
  4. xmlns:context="http://www.springframework.org/schema/context"
  5. xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
  6. xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:cache="http://www.springframework.org/schema/cache"
  7. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
  8. http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
  9. http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
  10. http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
  11. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
  12. http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
  13. http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
  14. http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd">
  15. <bean id="propertyConfigurer"
  16. class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  17. <property name="locations">
  18. <list>
  19. <value>classpath:dbconfig.properties</value>
  20. </list>
  21. </property>
  22. </bean>
  23. <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
  24. destroy-method="close">
  25. <property name="url" value="${url}" />
  26. <property name="username" value="${username}" />
  27. <property name="password" value="${password}" />
  28. <property name="driverClassName" value="${driverClassName}" />
  29. <property name="maxActive" value="${maxActive}" />
  30. <property name="initialSize" value="${initialSize}" />
  31. <property name="maxWait" value="${maxWait}" />
  32. <property name="minIdle" value="${minIdle}" />
  33. <property name="timeBetweenEvictionRunsMillis" value="${timeBetweenEvictionRunsMillis}" />
  34. <property name="minEvictableIdleTimeMillis" value="${minEvictableIdleTimeMillis}" />
  35. <property name="testWhileIdle" value="${testWhileIdle}" />
  36. <property name="testOnBorrow" value="${testOnBorrow}" />
  37. <property name="testOnReturn" value="${testOnReturn}" />
  38. <property name="maxOpenPreparedStatements" value="${maxOpenPreparedStatements}" />
  39. <property name="removeAbandoned" value="${removeAbandoned}" />
  40. <property name="removeAbandonedTimeout" value="${removeAbandonedTimeout}" />
  41. <property name="logAbandoned" value="${logAbandoned}" />
  42. <property name="proxyFilters">
  43. <list>
  44. <ref bean="wall-filter"/>
  45. </list>
  46. </property>
  47. </bean>
  48. <!-- 创建SqlSessionFactory,同时指定数据源 -->
  49. <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
  50. <property name="dataSource" ref="dataSource" />
  51. <property name="configLocation" value="classpath:mybatis-config.xml" />
  52. </bean>
  53. <!-- Spring自动扫描MybatisMapper文件 -->
  54. <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
  55. <property name="basePackage" value="com.tqe.dao" />
  56. </bean>
  57. <bean id="wall-filter" class="com.alibaba.druid.wall.WallFilter">
  58. <property name="dbType" value="mysql" />
  59. <property name="config" ref="wall-filter-config" />
  60. <property name="throwException" value="false"/>
  61. </bean>
  62. <bean id="wall-filter-config" class="com.alibaba.druid.wall.WallConfig" init-method="init">
  63. <property name="selectWhereAlwayTrueCheck" value="false"/>
  64. <property name="selectUnionCheck" value="false"/>
  65. <property name="dir" value="META-INF/druid/wall/mysql" />
  66. </bean>
  67. </beans>