Configuration of the DBCP

Source: Internet
Author: User

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&amp;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&amp;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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.