ZeYanG
2018-08-20 76a9f783560acf0eeca9bcd3c72d075c46af3bbb
commit | author | age
76a9f7 1 <?xml version="1.0" encoding="UTF-8"?>  
Z 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.javen" />  
14     
15     <!-- 引入配置文件 -->  
16     <bean id="propertyConfigurer"  
17         class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
18         <property name="location" value="classpath:application.properties" />  
19     </bean>  
20   
21     <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"  
22         destroy-method="close">  
23         <property name="driverClassName" value="${driver}" />  
24         <property name="url" value="${url}" />  
25         <property name="username" value="${username}" />  
26         <property name="password" value="${password}" />  
27         <!-- 初始化连接大小 -->  
28         <property name="initialSize" value="${initialSize}"></property>  
29         <!-- 连接池最大数量 -->  
30         <property name="maxActive" value="${maxActive}"></property>  
31         <!-- 连接池最大空闲 -->  
32         <property name="maxIdle" value="${maxIdle}"></property>  
33         <!-- 连接池最小空闲 -->  
34         <property name="minIdle" value="${minIdle}"></property>  
35         <!-- 获取连接最大等待时间 -->  
36         <property name="maxWait" value="${maxWait}"></property>  
37     </bean>  
38   
39     <!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 -->  
40     <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">  
41         <property name="dataSource" ref="dataSource" />  
42         <!-- 自动扫描mapping.xml文件 -->  
43          <!--<property name="mapperLocations" value="classpath:com/javen/mapping/*.xml"></property>   -->  
44     </bean>  
45   
46     <!-- DAO接口所在包名,Spring会自动查找其下的类 -->  
47     <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">  
48         <property name="basePackage" value="com.javen.dao" />  
49         <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>  
50     </bean>  
51   
52     <!-- (事务管理)transaction manager, use JtaTransactionManager for global tx -->  
53     <bean id="transactionManager"  
54         class="org.springframework.jdbc.datasource.DataSourceTransactionManager">  
55         <property name="dataSource" ref="dataSource" />  
56     </bean>  
57   
58 </beans>