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:context="http://www.springframework.org/schema/context" 5 xmlns:tx="http://www.springframework.org/schema/tx" 6 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 7 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> 8 9 <!-- 加载mysql数据配置文件 --> 10 <context:property-placeholder location="classpath:database.properties"/> 11 12 <!-- 配置datasource数据源对象 --> 13 <bean id="dataSource" class="com.mchange.v2.c3p0.mbean.C3P0PooledDataSource"> 14 <property name="driverClass" value="${jdbc.driver}" /> 15 <property name="jdbcUrl" value="${jdbc.url}" /> 16 <property name="user" value="${jdbc.username}" /> 17 <property name="password" value="${jdbc.password}" /> <Property name = "the maxPoolSize" value = "30" /> . 19 <! - Private property c3p0 data source -> 1820 is <Property name = "minPoolSize" value = "30" /> 21 is <-! After closing the connection does not automatically submit -> 22 is <Property name = "autoCommitOnClose" value = "to false" /> 23 is <! - obtaining a connection timeout -> 24 <Property name = "checkoutTimeout" value = "10000" /> 25 <-! obtain connection failure, the number of retries -> 26 is <Property name = "acquireIncrement" value = "2" /> 27 </ the bean> 28 29 <-! sqlSessionFactory Object configuration -> 30 <the bean ID = "sqlSessionFactory" class = "org.mybatis.spring. The SqlSessionFactoryBean "> 31 <-! Implantation database connection pool, here is why the ref because dataSource need is an object -?> 32 <Property name = "the dataSource" REF = "the dataSource" /> 33 is <-! Scanning package entity, alias (where the entity class package) -> 34 is <Property name = "typeAliasesPackage" value = "com.imooc .o2o.entity "/> 35 <- configuration mybatis global profile:! mybatis-the config.xml -> 36 <Property name =" the configLocation "value =" CLASSPATH: mybatis-the config.xml "/> 37 [ <! - scan sql profile: xml file mapper needs -> 38 is <Property name = "the mapperLocations" value = "CLASSPATH: mapper / * XML." /> 39 </ the bean> 40 41 is <! - DAO interface package configuration where the scan, to achieve dynamic DAO interface, is injected into the vessel spring -> 42 is <the bean class= "org.mybatis.spring.mapper.MapperScannerConfigurer"> 43 <-! injection sqlSessionFactory object here is why the value? Because sqlSessionFactoryBeanName needed is a string String -> 44 is <Property name = "sqlSessionFactoryBeanName" value = "SqlSessionFactory" /> 45 <Property name = "basePackage" value = "CLASSPATH: com.imooc.o2o.dao" /> 46 is </ the bean> 47 </ Beans>