您的位置:首页 > 编程语言 > Java开发

springmvc配置文件:spring-mybatis.xml

2017-11-18 00:02 429 查看
<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 

    xsi:schemaLocation="http://www.springframework.org/schema/beans

           http://www.springframework.org/schema/beans/spring-beans.xsd

           http://mybatis.org/schema/mybatis-spring

           http://mybatis.org/schema/mybatis-spring.xsd">

    <bean id="propertyConfigurer"  

        class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  

        <property name="location" value="classpath:project-db.properties" />  

    </bean>

 

    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"  

        destroy-method="close">  

        <property name="driverClassName" value="${driver}" />  

        <property name="url" value="${url}" />  

        <property name="username" value="${username}" />  

        <property name="password" value="${password}" />  

        <!-- 配置连接池的初始值 -->

        <property name="initialSize" value="1" />

        <!-- 连接池的最大值 -->

        <!-- <property name="maxActive" value="500"/> -->

        <!-- 最大空闲时,当经过一个高峰之后,连接池可以将一些用不到的连接释放,一直减少到maxIdle为止 -->

        <!-- <property name="maxIdle" value="2"/> -->

        <!-- 当最小空闲时,当连接少于minIdle时会自动去申请一些连接 -->

        <property name="minIdle" value="1" />

        <property name="maxActive" value="100" />

        <property name="maxIdle" value="20" />

        <property name="maxWait" value="1000" /> 

    </bean>

    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">  

        <property name="dataSource" ref="dataSource" />  

        <!-- 自动扫描mapping.xml文件 -->  

        <property name="mapperLocations" value="classpath:com/study/studymvc/mapper/*.xml"/>  

    </bean>

    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">  

        <property name="basePackage" value="com.study.studymvc.dao" />  

        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>  

    </bean>     

           

</beans>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐