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. cheerio & jQuery for server

    cheerio & jQuery for server Fast, flexible & lean implementation of core jQuery designed spe ...

  2. 钓鱼教程 All In One

    钓鱼教程 All In One youtube https://www.youtube.com/results?search_query=钓鱼教程&sp=CAM%3D 钓鱼证 https:// ...

  3. TypeScript 如何编写类库声明文件 .d.ts

    TypeScript 如何编写类库声明文件 .d.ts how to write a d.ts file declaration-files/ https://www.typescriptlang.o ...

  4. Google 灭霸 彩蛋

    Google 灭霸 彩蛋 在Google中搜索"灭霸",然后在右侧点击的"无限手套",页面的一些搜索项就会随机性像沙子一样的消失(后面统称沙化效果),特别的炫酷 ...

  5. CentOS 7.6.1810 运行pupperteer

    故障排除 安装puppeteer,使用cnpm 解决依赖 $ yum -y update $ yum install -y pango libXcomposite libXcursor libXdam ...

  6. Java volatile 关键字底层实现原理解析

    本文转载自Java volatile 关键字底层实现原理解析 导语 在Java多线程并发编程中,volatile关键词扮演着重要角色,它是轻量级的synchronized,在多处理器开发中保证了共享变 ...

  7. JS广度优先遍历

    自己用JS实现了 广度优先遍历 第一种用了数组的高阶函数,看起来有些复杂.然后思索着从可读性上优化了一下,孰优孰劣以后分析. var list = [{ id: "ab", chi ...

  8. synchronized语法

    synchronized( ){ } synchronized 关键字是加锁的意思,用它来修饰方法就表示给该方法加了锁,从而达到线程同步的效果;用它来修饰代码块就表示给该代码块加了锁,从而达到线程同步 ...

  9. 腾讯数据库tdsql部署与验证

    环境准备 | 主机 | IP | 配置(最低要求配置) | | :----- | ------------- | ------------------ | | node-1 | 192.168.1.8 ...

  10. Java基础语法:注释

    书写注释是一个非常好的习惯. 注释并不会被执行,是给我们写代码的人看的. Java中的注释有三种: 单行注释(Line comment) 多行注释(Block comment) 文档注释(JavaDo ...