spring配置mybatis3
mybatis官方网站:http://www.mybatis.org/mybatis-3/zh/configuration.html
<!--第一步:加载配置数据库相关参数-->
<context:property-placeholder location="classpath:jdbc.properties"></context:property-placeholder>
<!--第二步:数据库连接池-->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
init-method="init" destroy-method="close">
<!--配置连接池属性-->
<property name="driverClassName" value="${jdbc.driverClass}"></property>
<property name="url" value="${jdbc.url}"></property>
<property name="username" value="${jdbc.username}"></property>
<property name="password" value="${jdbc.password}"></property>
<!-- 配置初始化大小、最小、最大 -->
<property name="initialSize" value="1" />
<property name="minIdle" value="1" />
<property name="maxActive" value="20" />
<!-- 配置获取连接等待超时的时间 -->
<property name="maxWait" value="60000" />
<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
<property name="timeBetweenEvictionRunsMillis" value="60000" />
<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
<property name="minEvictableIdleTimeMillis" value="300000" />
</bean>
<!-- 第三步:sqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="configLocation" value="classpath:mybatis-config.xml"/>
<property name="mapperLocations" value="classpath*:com/eaglesoul/assistant/dao/mapper/*.mapper"/>
<property name="dataSource" ref="dataSource"/>
</bean>
<!-- 第四步:配置mapper接口,创建动态代理类,并注册到ioc容器 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.eaglesoul.assistant.dao"/>
</bean>
mybatis-config.xml配置文件:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<setting name="cacheEnabled" value="true"/>
<setting name="lazyLoadingEnabled" value="true"/>
<setting name="mapUnderscoreToCamelCase" value="true"/>
</settings>
</configuration>
spring配置mybatis3的更多相关文章
- Spring4.X + spring MVC + Mybatis3 零配置应用开发框架搭建详解(1) - 基本介绍
Spring4.X + spring MVC + Mybatis3 零配置应用开发框架搭建详解(1) - 基本介绍 spring集成 mybatis Spring4.x零配置框架搭建 两年前一直在做后 ...
- Spring配置c3p0数据源时出错报:java.lang.NoClassDefFoundError: com/mchange/v2/ser/Indirector
今天在使用Spring配置c3p0数据源时,使用的数据库是mysql,服务器是tomcat,运行时报了一个 java.lang.NoClassDefFoundError: com/mchange/v2 ...
- Spring配置汇总
现在主流的JavaWeb应用几乎都会用到Spring,以下是Spring的配置,以及结合Web的SpringMVC配置的汇总. jar包的引入 与Web项目集成 Spring配置文件 SpringMV ...
- spring配置属性的两种方式
spring配置属性有两种方式,第一种方式通过context命名空间中的property-placeholder标签 <context:property-placeholder location ...
- 解决eclipse spring配置报错:cvc-elt.1: Cannot find the declaration of element
解决eclipse spring配置报错:cvc-elt.1: Cannot find the declaration of element 'beans'.Referenced file conta ...
- spring配置详解
1.前言 公司老项目的后台,均是基于spring框架搭建,其中还用到了log4j.jar等开源架包.在新项目中,则是spring和hibernate框架均有使用,利用了hibernate框架,来实现持 ...
- memcached 学习 1—— memcached+spring配置
memcached 学习目录: memcached 学习 1—— memcached+spring配置 这几天自己搭建项目环境,解决问题如下: 有关常见的配置这里没有列出,中间遇到的搭建问题比较顺利g ...
- 解决spring配置中的bean类型的问题:BeanNotOfRequiredTypeException
解决spring配置中的bean类型的问题:BeanNotOfRequiredTypeException这个问题出现的原因:一般在使用annotation的方式注入spring的bean 出现的,具体 ...
- spring配置中,properties文件以及xml文件配置问题
spring方便我们的项目快速搭建,功能强大,自然也会是体系复杂! 这里说下配置文件properties管理的问题. 一些不涉及到代码逻辑,仅仅只是配置数据,可以放在xxxx.properties文件 ...
随机推荐
- PostgreSQL函数如何返回数据集 [转]
PostgreSQL函数如何返回数据集 以下主要介绍PostgreSQL函数/存储过程返回数据集,或者也叫结果集的示例. 背景: PostgreSQL里面没有存储过程,只有函数,其他数据库里的这两个对 ...
- Visual Studio使用技巧学习
F7: 代码窗口 Shift+F7: 对象窗口 F4: 属性窗口 闪电图标: 对象的事件 F5: 编译及运行 Ctrl+F5: 编译及运行(不调试) svm+两次Tab: s ...
- 倒计时器 CountDownTimer
使用介绍 开发中经常会遇到一些和倒计时有关的场景,比如发送验证码的按钮,会在点击发送后,显示倒计时间,倒计时结束后才能够刷新按钮,再次允许点击.为了不阻塞软件的运行,又要实时刷新界面,我们通常会用到 ...
- spring @RequestBody 和 @RequestParams 同时使用
@RequestBody 和 @RequestParams 是可以同时使用的. @RequestBody 接受的数据类型是 content-type:"application/json&qu ...
- PL/SQL学习笔记(二)
select * from protype;select * from product;---笛卡尔连接查询(交叉连接)select * from protype,product;select * f ...
- 使用office 365打开excel文件报错,提示“向程序发送命令时出现问题”
我买了一套正版的office 365装在我的windows10 上.但是每次打开excel都会报错,如图一.求教了微软技术人员,他们给出了以下办法: 图一 方法一: 修复安装Office ====== ...
- (转)SpringMVC学习(三)——SpringMVC的配置文件
http://blog.csdn.net/yerenyuan_pku/article/details/72231527 读者阅读过SpringMVC学习(一)——SpringMVC介绍与入门这篇文章后 ...
- stringstream clear与str("")的问题
一.str与clear函数 C++Reference对于两者的解释: 可见:clear()用来设置错误状态,相当于状态的重置:str用来获取或预置内容 二.区别 运行下面测试代码: #include& ...
- JS常用操作节点的方法
js常见的创建dom节点的方法有 createElement() 创建一个元素节点 => 接收参数为string类型的nodename createTextNode() 创建一个文本节点 =&g ...
- 快学UIautomator之uiautomatorhelp使用
1.先下载uiautomatorhelp插件 2.把uiautomatorhelp.java包放到自己的项目中 3.项目中引入uiautomatorhelp插件 4.在项目中设置一个main方法,引入 ...