Mybatis核心配置文件:

配置文件内可以不写内容

<?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="" value=""/>
</settings>--> </configuration>

Spring核心配置文件

<?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"
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"> <!--引入db.properties配置文件-->
<context:property-placeholder location="db.properties"></context:property-placeholder>
<!--注解扫描包-->
<context:component-scan base-package="com.xxx"></context:component-scan>
<!--数据源-->
<bean id="ds" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<!--驱动类名-->
<property name="driverClass" value="${driver}"></property>
<!--url-->
<property name="jdbcUrl" value="${url}"></property>
<!--用户名-->
<property name="user" value="${name}"></property>
<!--密码-->
<property name="password" value="${pwd}"></property>
<!--当连接池中的连接耗尽的时候c3p0一次同时获取的连接数-->
<property name="acquireIncrement" value="5"></property>
<!--初始连接池大小-->
<property name="initialPoolSize" value="10"></property>
<!--连接池中连接最小个数-->
<property name="minPoolSize" value="5"></property>
<!--连接池中连接最大个数-->
<property name="maxPoolSize" value="20"></property>
</bean>

    Mybatis与Spring整合配置:

    SqlSessionFactoryBean:Mybatis整合Spring核心API之一

    <!--Mybatis相关配置-->
<!--工厂对象-->
<bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
<!--数据源-->
<property name="dataSource" ref="ds"></property>
<!--别名包-->
<property name="typeAliasesPackage" value="com.xxx.pojo"></property>
<!--映射文件:加载映射文件(xxxMapper.xml)-->
<property name="mapperLocations" value="classpath:mapper/*Mapper.xml"></property>
<!--读取mybatis核心配置文件:其它mybatis核心配置文件中定义的内容-->
<property name="configLocation" value="mybatis-comfig.xml"></property>
</bean>

    MapperScannerConfigurer:MyBatis整合Spring核心API之一

    扫描接口:

    <!--将所有的接口对象注入到容器中-->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactoryBean"></property>
<!--接口所在位置-->
<property name="basePackage" value="com.xxx.mapper"></property>
</bean> </beans>

Spring与Mybatis整合配置的更多相关文章

  1. spring和mybatis整合配置

    <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...

  2. SSM Spring +SpringMVC+Mybatis 整合配置 及pom.xml

    SSM Spring +SpringMVC+Mybatis 配置 及pom.xml SSM框架(spring+springMVC+Mybatis) pom.xml文件 maven下的ssm整合配置步骤

  3. Spring+SpringMVC+MyBatis整合配置

    前端控制器 web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app version=& ...

  4. spring, spring mvc, mybatis整合文件配置详解

    转自:http://www.cnblogs.com/wxisme/p/4924561.html 使用SSM框架做了几个小项目了,感觉还不错是时候总结一下了.先总结一下SSM整合的文件配置.其实具体的用 ...

  5. Spring+springmvc+Mybatis整合案例 xml配置版(myeclipse)详细版

    Spring+springmvc+Mybatis整合案例 Version:xml版(myeclipse) 文档结构图: 从底层开始做起: 01.配置web.xml文件 <?xml version ...

  6. idea spring+springmvc+mybatis环境配置整合详解

    idea spring+springmvc+mybatis环境配置整合详解 1.配置整合前所需准备的环境: 1.1:jdk1.8 1.2:idea2017.1.5 1.3:Maven 3.5.2 2. ...

  7. Spring+springmvc+Mybatis整合案例 annotation版(myeclipse)详细版

    Spring+springmvc+Mybatis整合案例 Version:annotation版 文档结构图: 从底层开始做起: 01.配置web.xml文件 <?xml version=&qu ...

  8. Spring与Mybatis整合的MapperScannerConfigurer处理过程源码分析

    前言 本文将分析mybatis与spring整合的MapperScannerConfigurer的底层原理,之前已经分析过java中实现动态,可以使用jdk自带api和cglib第三方库生成动态代理. ...

  9. Mybatis学习--spring和Mybatis整合

    简介 在前面写测试代码的时候,不管是基于原始dao还是Mapper接口开发都有许多的重复代码,将spring和mybatis整合可以减少这个重复代码,通过spring的模板方法模式,将这些重复的代码进 ...

随机推荐

  1. postion:fixed和margin:0 auto的使用

    很多同学将顶部菜单固定,使用postion:fixed,然后使用margin:0 auto进行居中,发现margin:0 auto并不起作用. 通常,我们要让某元素居中,会这样做: #element{ ...

  2. SEO & JSON-LD & structured-data

    SEO & JSON-LD & structured-data script type="application/ld+json" script type=&quo ...

  3. react new features 2020

    react new features 2020 https://insights.stackoverflow.com/survey/2019#technology-_-web-frameworks h ...

  4. webpack defineConstants

    webpack defineConstants PAGES 全局常量/全局变量 https://webpack.js.org/plugins/define-plugin/ taro https://n ...

  5. 微信小程序 components

    微信小程序 components wx-xcx-components https://developers.weixin.qq.com/miniprogram/dev/component/ https ...

  6. NGK数字钱包的特点是什么?NGK钱包的优点和缺点是什么?

    说起区块链数字资产,那就离不开谈到数字钱包.数字钱包不仅有资产管理的功能,还可以进行资产理财.资产交易,甚至能为公链DAPP导流. 对于NGK公链而言,其数字钱包已然成为了解NGK公链的基础条件.NG ...

  7. SpringBoot接收map类型的参数

    如果某个controller的某个接口的参数特别多,也可以使用map的方式来接收参数,接收之后使用get方法获取即可. 1)get请求方式,定义map接收方式 @RequestParam(requir ...

  8. 使用 xunit 编写测试代码

    使用 xunit 编写测试代码 Intro xunit 是 .NET 里使用非常广泛的一个测试框架,有很多测试项目都是在使用 xunit 作为测试框架,不仅仅有很多开源项目在使用,很多微软的项目也在使 ...

  9. js 前端MD5加密

    1.引入 <script src="https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.js"></script& ...

  10. Elastic App Search 快速构建 ES 应用

    公号:码农充电站pro 主页:https://codeshellme.github.io App Search 是 Elastic 家族中的一个产品,它可以帮助我们(基于 ES)快速高效的构建搜索应用 ...