spring-mybatis.xml 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. xmlns:p="http://www.springframework.org/schema/p"
  5. xmlns:context="http://www.springframework.org/schema/context"
  6. xmlns:mvc="http://www.springframework.org/schema/mvc"
  7. xmlns:tx="http://www.springframework.org/schema/tx"
  8. xmlns:aop="http://www.springframework.org/schema/aop"
  9. xsi:schemaLocation="http://www.springframework.org/schema/beans
  10. http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
  11. http://www.springframework.org/schema/context
  12. http://www.springframework.org/schema/context/spring-context-4.0.xsd
  13. http://www.springframework.org/schema/mvc
  14. http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
  15. http://www.springframework.org/schema/tx
  16. http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
  17. http://www.springframework.org/schema/aop
  18. http://www.springframework.org/schema/aop/spring-aop-4.0.xsd">
  19. <bean name="dataSource"
  20. class="com.alibaba.druid.pool.DruidDataSource" init-method="init"
  21. destroy-method="close">
  22. <property name="url" value="${jdbc_url}" />
  23. <property name="username" value="${jdbc_username}" />
  24. <property name="password" value="${jdbc_password}" />
  25. <!-- 初始化连接大小 -->
  26. <property name="initialSize" value="0" />
  27. <!-- 连接池最大使用连接数量 -->
  28. <property name="maxActive" value="20" />
  29. <!-- 连接池最大空闲 -->
  30. <property name="maxIdle" value="20" />
  31. <!-- 连接池最小空闲 -->
  32. <property name="minIdle" value="0" />
  33. <!-- 获取最大等待时间 -->
  34. <property name="maxWait" value="60000" />
  35. <property name="validationQuery" value="${validationQuery}" />
  36. <property name="testOnBorrow" value="false" />
  37. </bean>
  38. <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
  39. <property name="dataSource" ref="dataSource" />
  40. <!-- 自动扫描目录 -->
  41. <property name="mapperLocations" value="classpath:mapper/*.xml" />
  42. <!-- 设置配置文件地路径 分页插件配置文件 -->
  43. <property name="configLocation" value="classpath:config/mybatis-plugin.xml" />
  44. </bean>
  45. <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
  46. <property name="basePackage" value="com.e3.zl.wc.dao" />
  47. <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
  48. </bean>
  49. <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx -->
  50. <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  51. <property name="dataSource" ref="dataSource" />
  52. </bean>
  53. <!-- 注解控制事务 -->
  54. <tx:annotation-driven transaction-manager="transactionManager" />
  55. </beans>