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. Get your site working on Google Search Console , 在 Google Search Console中运行您的网站, Google Search Console

    1 1 https://support.google.com/webmasters/topic/4564315? Search Console Help SEARCH CONSOLEHELP FORU ...

  2. how to enable vue cli auto open the localhost url

    how to enable vue cli auto open the localhost URL bad you must click the link by manually, waste of ...

  3. .NET & C# & ASP.NET

    .NET && C# && ASP.NET https://docs.microsoft.com/zh-cn/dotnet/ .NET Documentation We ...

  4. 微信小程序-云开发实战教程

    微信小程序-云开发实战教程 云函数,云存储,云数据库,云调用 https://developers.weixin.qq.com/miniprogram/dev/wxcloud/basis/gettin ...

  5. javascript & global event & custom event

    javascript & global event & custom event new CustomEvent object let event = new CustomEvent( ...

  6. Flutter 使用p5

    p5 工作示例 install dependencies: p5: ^0.0.5 main.dart import 'package:flutter/material.dart'; import &q ...

  7. RocketMq灰皮书(一)------选型&RocketMQ名词

    RocketMq灰皮书(一)------选型&RocketMQ名词 一. MQ选型对比 目前业内常用的MQ框架有一下几种: Kafka RabbitMQ RocketMQ 除此之外,还有Act ...

  8. Java SE7虚拟机指令操作码助记符

    本文转载自Java SE7 虚拟机指令操作码助记符 导语 在Class文件中,Java方法里的方法体,也就是代表着一个Java源码程序中程序的部分存储在方法表集合的Code属性中.存储在Code属性中 ...

  9. Django Admin 在内联中覆盖保存方法(admin.TabularInline)

    一  使用环境 开发系统: windows IDE: pycharm 数据库: msyql,navicat 编程语言: python3.7  (Windows x86-64 executable in ...

  10. POJ-3159(差分约束+Dijikstra算法+Vector优化+向前星优化+java快速输入输出)

    Candies POJ-3159 这里是图论的一个应用,也就是差分约束.通过差分约束变换出一个图,再使用Dijikstra算法的链表优化形式而不是vector形式(否则超时). #include< ...