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. React Hooks: useContext All In One

    React Hooks: useContext All In One useContext https://reactjs.org/docs/hooks-reference.html#useconte ...

  2. CSS multi colors circle

    CSS multi colors circle <!DOCTYPE html> <html lang="zh-Hans"> <head> < ...

  3. WebIDE All In One

    WebIDE All In One web IDE Visual Studio Code vscode Code editing Redefined. Free. Built on open sour ...

  4. 前端 vs 后端

    前端 vs 后端 前端与后端: 有什么区别? 前端和后端是计算机行业中最常用的两个术语. 在某种程度上,它们成了流行语. 它们决定了您作为软件开发人员所从事的工作类型,所使用的技术以及所获得的收入. ...

  5. DOM & Node.contains

    DOM & Node.contains Node.contains() https://developer.mozilla.org/en-US/docs/Web/API/Node/contai ...

  6. NGK公链账本技术浅析

    NGK公链账本是一个去中心化加密账本,运行在分布式网络上.分布式账本是区块链技术中最重要的组成部分之一.NGK作为公链资产,在公链中起到桥梁作用,可以促进其他资产(法币.数字资产.股权以及实物资产)交 ...

  7. 如何用JavaDoc命令生成帮助文档

    如何用JavaDoc命令生成帮助文档 文档注释 在代码中使用文档注释的方法 /** *@author *@version * */ 生成帮助文档 打开java文件所在位置,在路径前加入cmd (注意有 ...

  8. 16_MySQL聚合函数的使用(重点,建议大家多动手操作)

    本节所涉及的SQL语句 -- 聚合函数 SELECT AVG(sal+IFNULL(comm,0)) AS avg FROM t_emp; -- SUM SELECT SUM(sal) FROM t_ ...

  9. MFC多文档程序启动无子窗口的实现

    刚学MFC的我们,肯定会从一个基本MFC程序开始. 而VC++6.0的MFC基础类提供了三种创建方式:单文档.多文档.对话框. 当我们创建多文档应用程序的时候,会自动启动一个子窗口. 在我们平时使用软 ...

  10. 在js中如何将字符串类型的日期("2020-11-30T02:21:42.000+0000")进行格式化

    1.引入方法 import { formatDateNew } from '@/utils' 2.在方法中使用,注意要先将字符串进行new Date(),否则报错date.getFullYear is ...