<?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:tx="http://www.springframework.org/schema/tx"
xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">

<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="${db.bbs.url}"/>
<property name="username" value="${db.bbs.username}"/>
<property name="password" value="${db.bbs.password}"/>
<!-- 配置初始化大小、最小、最大 -->
<property name="initialSize" value="2"/>
<property name="minIdle" value="2"/>
<property name="maxActive" value="${db.bbs.maxPoolSize}"/>
<!-- 配置获取连接等待超时的时间 -->
<property name="maxWait" value="60000"/>

<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
<property name="timeBetweenEvictionRunsMillis" value="3000"/>
<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
<property name="minEvictableIdleTimeMillis" value="300000"/>
<property name="validationQuery" value="SELECT 'x'"/>
<property name="testWhileIdle" value="true"/>

<!-- 这里建议配置为true,防止取到的连接不可用 -->
<property name="testOnBorrow" value="true"/>
<property name="testOnReturn" value="false"/>

<!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
<property name="poolPreparedStatements" value="true"/>
<property name="maxPoolPreparedStatementPerConnectionSize" value="20"/>

<!-- 获取数据库连接的时候执行sql:set names utf8mb4; -->
<property name="connectionInitSqls" value="set names utf8mb4 ;"/>

<!-- 配置监控统计拦截的filters -->
<property name="filters" value="stat"/>
<!-- 配置关闭长时间不使用的连接 -->
<!-- 是否清理removeAbandonedTimeout秒没有使用的活动连接,清理后并没有放回连接池(针对未被close的活动连接) -->
<property name="removeAbandoned" value="true"/>
<!-- 活动连接的最大空闲时间,1800秒,也就是30分钟 -->
<property name="removeAbandonedTimeout" value="1800"/>
<!-- 连接池收回空闲的活动连接时是否打印消息 -->
<property name="logAbandoned" value="true"/>
</bean>

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="typeAliasesPackage" value="com.inborn.inshop.model" />
<!-- mapper and resultmap path -->
<property name="mapperLocations">
<list>
<value>classpath*:mapper/**/*.xml</value>
</list>
</property>
<property name="plugins">
<array>
<bean class="com.github.pagehelper.PageHelper">
<property name="properties">
<value>
dialect=mysql
reasonable=true
</value>
</property>
</bean>
</array>
</property>
</bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.inborn.inshop.mapper" />
</bean>
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory" />
</bean>

</beans>

spring 配置ibatis和自动分页的更多相关文章

  1. Spring整合Ibatis

    Spring整合Ibatis javaibatisspring 所需jar清单           ibatis-2.*.jar    *为任意版本,下同,ibatis工作包           sp ...

  2. 搭建基于SSI(struts2,spring,ibatis)的javaEE开发环境

    搭建基于SSI(struts2,spring,ibatis)的javaEE开发环境 最近有很多人不知道如何搭建基于SSI(struts2,spring,ibatis)的J2EE开发环境,这里给大家一个 ...

  3. spring+struts2+ibatis 框架整合以及解析

    一. spring+struts2+ibatis 框架 搭建教程 参考:http://biancheng.dnbcw.net/linux/394565.html 二.分层 1.dao: 数据访问层(增 ...

  4. spring+jotm+ibatis+mysql实现JTA分布式事务

    1 环境 1.1 软件环境  spring-framework-2.5.6.SEC01-with-dependencies.zip ibatis-2.3.4 ow2-jotm-dist-2.1.4-b ...

  5. spring+springmvc+ibatis整合注解方式实例【转】

    源自-----> http://shaohan126448.iteye.com/blog/2033563 (1)web.xml文件(Tomcat使用) 服务器根据配置内容初始化spring框架, ...

  6. spring+springmvc+ibatis整合注解方式实例

    需求说明 实现用户通过数据库验证登录需求.採用 Myeclipse+Tomcat 6.0+Mysql 5.0+JDK 1.6 2.数据库表 开发所用是Mysql数据库,仅仅建立单张用户表T_USER, ...

  7. mybatis+spring配置

    可参考:http://www.javacodegeeks.com/2014/02/building-java-web-application-using-mybatis-with-spring.htm ...

  8. 基于 Spring 和 iBATIS 的动态可更新多数据源持久层

    前言 我们时常会遇到一些 web 项目,需要从不同的数据源中抓取数据来进行分析,而这些数据源是有可能变化的,需要用户来进行动态的维护和添加.可是,大多数的 web 程序使用了应用服务器或者容器中间件来 ...

  9. Spring 整合 ibatis

    是的,真的是那个不好用的ibatis,不是好用的mybatis. 由于工作需要用到ibatis需要自己搭建环境,遇到了不少的坑,做一下记录. 一.环境配置 Maven JDK1.6 (非常重要,使用S ...

随机推荐

  1. c# 静态方法和数据

    c#所有方法都必须在类的内部声明,但如果把方法或者字段声明为static就可以使用,类名代用方法或者访问字段. 在方法中声明一个静态变量a 和一个静态的aFun方法.下面是在主函数中调用. 从上图可以 ...

  2. sqlyog连接Linux上的mysql报错误号码2013,错误号码1130的解决办法

    sqlyog连接Linux上的mysql报错误号码2013,错误号码1130的解决办法 1.报错误号码2013,可能是端口号不是默认的3306,需要改成对应的,检查命令是: [root@host et ...

  3. javamail邮件Multipart支持同时发text和html混合消息,alternative纯文本与超文本共存

    javamail邮件Multipart支持同时发text和html混合消息alternative纯文本与超文本共存 multipart/mixed:附件. multipart/related:内嵌资源 ...

  4. Hadoop学习笔记之四:HDFS客户端

    HDFS的客户端核心是DFSClient类,所有使用HDFS的客户端都会持有一个DFSClient对象,或通过持有一个DistributedFileSystem对象间接使用DFSClient: DFS ...

  5. 事务 c#

    事务->:事务是恢复和并发控制的基本单位 ->事务具有四个特性:原子性.隔离性.一致性.持久性.这四个特性通常称为ACID Begin transaction/tran   --开始事务 ...

  6. TCP/IP协议三次握手与四次挥手

    一.标志位和序号 seq序号 :发送方随机生成的 ack确认序号:ack=seq+1 标志位ACK=1时确认序号有效 SYN标志位:发起一个新连接 ACK标志位:确认序号有效 FIN标志位:断开连接 ...

  7. 解决mySQL占用内存超大问题

    为了装mysql环境测试,装上后发现启动后mysql占用了很大的虚拟内存,达8百多兆.网上搜索了一下,得到高人指点my.ini.再也没见再详细的了..只好打开my.ini逐行的啃,虽然英文差了点,不过 ...

  8. c++ STL中的set和multiset

    1.结构 set和multiset会根据特定的排序原则将元素排序.两者不同之处在于,multisets允许元素重复,而set不允许重复. set中的元素可以是任意类型的,但是由于需要排序,所以元素必须 ...

  9. 初识wxPython

    wxPython是包装C++编写的wxWidgets跨平台的GUI组件 安装wxPython pip install wxpython import wx def load(event): file ...

  10. python之面向对象的高级进阶

    一 .isinstance(obj,cls)和issubclass(sub,super) isinstance(obj,cls)检查是否obj是否是类 cls 的对象 class Foo(object ...