018/5/8 12:12:11
<!--turn on the appropriate annotation processor and specify the scan path--
<context:component-scan base-package= "org.ch09"/>
<!--data source, DBCP connection pool--
<bean id= "DataSource" class= "Org.apache.commons.dbcp.BasicDataSource" >
<property name= "Driverclassname" value= "Com.mysql.jdbc.Driver"/>
<property name= "url" value= "Jdbc:mysql://localhost:3306/test?useunicode=true&characterencoding=utf-8" />
<property name= "username" value= "root"/>
<property name= "Password" value= "root"/>
<property name= "InitialSize" value= "5"/>
<property name= "maxactive" value= "/>"
<property name= "Minidle" value= "ten"/>
<property name= "maxwait" value= "/>"
</bean>
<!--configuration MyBatis Sqlsessionfactorybean--
<bean id= "Sqlsessionfactorybean" class= "Org.mybatis.spring.SqlSessionFactoryBean" >
<!--injecting data sources--
<property name= "DataSource" ref= "DataSource"/>
<!--Set the default alias for the entity entity under the specified package--
<property name= "Typealiasespackage" value= "org.ch09.entity"/>
<!--Configure the Mapper mapping file path (if you use the Mapper mapping profile you need to specify)-
<property name= "mapperlocations" value= "Classpath*:mapper/*.xml"/>
</bean>
<!--Configure the MyBatis mapperscannerconfigurer to scan the corresponding mapper interface (that is, the corresponding DAO interface)--
<bean id= "Mapperscanner" class= "Org.mybatis.spring.mapper.MapperScannerConfigurer" >
<!--just specify the path to the package where the DAO interface is located--
<property name= "Basepackage" value= "Org.ch09.dao"/>
</bean>
<!--Configuring the JDBC transaction Manager--
<bean id= "Txmanager" class= "Org.springframework.jdbc.datasource.DataSourceTransactionManager" >
<!--injecting data sources--
<property name= "DataSource" ref= "DataSource"/>
</bean>
<!--enable annotation transaction-driven
<tx:annotation-driven transaction-manager= "Txmanager"/>
<?xml version= "1.0" encoding= "UTF-8"?>
<beans xmlns= "Http://www.springframework.org/schema/beans"
Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance
"
xmlns:context= "Http://www.springframework.org/schema/context"
xmlns:tx= "Http://www.springframework.org/schema/tx"
Xsi:schemalocation= "Http://www.springframework.org/schema/beans
Http://www.springframework.org/schema/beans/spring-beans.xsd
Http://www.springframework.org/schema/context
Http://www.springframework.org/schema/context/spring-context.xsd
Http://www.springframework.org/schema/tx
Http://www.springframework.org/schema/tx/spring-tx.xsd ">
<!--turn on the appropriate annotation processor and specify the scan path--
<context:component-scan base-package= "org.ch09"/>
<!--data source, DBCP connection pool--
<bean id= "DataSource" class= "Org.apache.commons.dbcp.BasicDataSource" >
<property name= "Driverclassname" value= "Com.mysql.jdbc.Driver"/>
<property name= "url" value= "Jdbc:mysql://localhost:3306/test?useunicode=true&characterencoding=utf-8" />
<property name= "username" value= "root"/>
<property name= "Password" value= "root"/>
<property name= "InitialSize" value= "5"/>
<property name= "maxactive" value= "/>"
<property name= "Minidle" value= "ten"/>
<property name= "maxwait" value= "/>"
</bean>
<!--configuration MyBatis Sqlsessionfactorybean--
<bean id= "Sqlsessionfactorybean" class= "Org.mybatis.spring.SqlSessionFactoryBean" >
<!--injecting data sources--
<property name= "DataSource" ref= "DataSource"/>
<!--Set the default alias for the entity entity under the specified package--
<property name= "Typealiasespackage" value= "org.ch09.entity"/>
<!--Configure the Mapper mapping file path (if you use the Mapper mapping profile you need to specify)-
<property name= "mapperlocations" value= "Classpath*:mapper/*.xml"/>
</bean>
<!--Configure the MyBatis mapperscannerconfigurer to scan the corresponding mapper interface (that is, the corresponding DAO interface)--
<bean id= "Mapperscanner" class= "Org.mybatis.spring.mapper.MapperScannerConfigurer" >
<!--just specify the path to the package where the DAO interface is located--
<property name= "Basepackage" value= "Org.ch09.dao"/>
</bean>
<!--Configuring the JDBC transaction Manager--
<bean id= "Txmanager" class= "Org.springframework.jdbc.datasource.DataSourceTransactionManager" >
<!--injecting data sources--
<property name= "DataSource" ref= "DataSource"/>
</bean>
<!--enable annotation transaction-driven
<tx:annotation-driven transaction-manager= "Txmanager"/>
</beans>
Configuration of the DBCP