fbd42fa8d72144e9661ac4ab85a3e8b1fca88f08.svn-base 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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:mvc="http://www.springframework.org/schema/mvc"
  6. xsi:schemaLocation="http://www.springframework.org/schema/beans
  7. http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
  8. http://www.springframework.org/schema/context
  9. http://www.springframework.org/schema/context/spring-context-3.1.xsd
  10. http://www.springframework.org/schema/mvc
  11. http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
  12. <!-- 自动扫描 -->
  13. <context:component-scan base-package="com.synyi.edc" />
  14. <!-- 引入配置文件 -->
  15. <bean id="propertyConfigurer"
  16. class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  17. <property name="location" value="classpath:jdbc.properties" />
  18. </bean>
  19. <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
  20. destroy-method="close">
  21. <property name="driverClassName" value="${driver}" />
  22. <property name="url" value="${url}" />
  23. <property name="username" value="${username}" />
  24. <property name="password" value="${password}" />
  25. <!-- 初始化连接大小 -->
  26. <property name="initialSize" value="${initialSize}"></property>
  27. <!-- 连接池最大数量 -->
  28. <property name="maxActive" value="${maxActive}"></property>
  29. <!-- 连接池最大空闲 -->
  30. <property name="maxIdle" value="${maxIdle}"></property>
  31. <!-- 连接池最小空闲 -->
  32. <property name="minIdle" value="${minIdle}"></property>
  33. <!-- 获取连接最大等待时间 -->
  34. <property name="maxWait" value="${maxWait}"></property>
  35. </bean>
  36. <!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 -->
  37. <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
  38. <property name="dataSource" ref="dataSource" />
  39. <!-- 自动扫描mapping.xml文件 -->
  40. <property name="mapperLocations" value="classpath:mapping/*.xml"></property>
  41. </bean>
  42. <!-- DAO接口所在包名,Spring会自动查找其下的类 -->
  43. <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
  44. <property name="basePackage" value="com.synyi.edc.dao" />
  45. <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
  46. </bean>
  47. <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx -->
  48. <bean id="transactionManager"
  49. class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  50. <property name="dataSource" ref="dataSource" />
  51. </bean>
  52. </beans>