zoukankan      html  css  js  c++  java
  • mybatis的配置

    <?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-4.2.xsd
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd">
    
    <!--     <bean id="configer" -->
    <!--         class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> -->
    <!--         <property name="location" value="classpath:application.properties"></property> -->
    <!--     </bean> -->
        <context:component-scan base-package="com.service"/>
        <!-- 使用 dbcp2 来管理 数据库连接 -->
        <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource"
            destroy-method="close">
            <property name="driverClassName" value="${driver}"></property>
            <property name="username" value="${username}"></property>
            <property name="password" value="${password}"></property>
            <property name="initialSize" value="${initialSize}"></property>
            <property name="url" value="${url}"></property>
            <property name="maxTotal" value="${maxTotal}"></property>
            <property name="maxIdle" value="${maxIdle}"></property>
            <property name="minIdle" value="${minIdle}"></property>
            <property name="maxWaitMillis" value="${maxWait}"></property>
            <property name="defaultAutoCommit" value="false"></property>
            <!-- 连接空闲后一段时间 被逐出连接池的时间 毫秒 -->
            <property name="minEvictableIdleTimeMillis" value="120000"></property>
        </bean>
    
        <!-- mybatis 持久化实例 准备 所有的 DAO 对象 -->
        <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
            <property name="dataSource" ref="dataSource"></property>
            <!-- 读取配置文件 -->
            <property name="mapperLocations" value="classpath:mapper/*.xml"></property>
        </bean>
    
        <!-- 查找 DAO 并将其 放入 spring 容器中便于管理 -->
        <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
            <property name="basePackage" value="com.dao"></property>
            <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
        </bean>
    
        <!-- spring 事务声明 -->
        <bean id="transactionManager"
            class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
            <property name="dataSource" ref="dataSource"></property>
        </bean>
    
        <!-- 事务注解驱动,标注@Transactional的类和方法将具有事务性 -->
        <tx:annotation-driven transaction-manager="transactionManager" />
    </beans>
    View Code
  • 相关阅读:
    检测当前浏览器及版本
    js 实现两个小数的相乘、相除功能
    echarts图表初始大小问题及echarts随窗口变化自适应
    element-ui走马灯如何实现图片自适应 长度和高度 自适应屏幕大小
    vue中淡入淡出示例
    CSS3------box-shadow,即单边阴影效果设置
    webpack4 自学笔记五(tree-shaking)
    webpack4 自学笔记四(style-loader)
    webpack4 自学笔记三(提取公用代码)
    webpack4 自学笔记二(typescript的配置)
  • 原文地址:https://www.cnblogs.com/javaweb2/p/6257221.html
Copyright © 2011-2022 走看看