<?xml version="1.0" encoding="UTF8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <!--DataSource:使用Spring的数据源替换Mybatis的配置 -->
<bean id="datasource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/mybatis?userSSL=true&amp;userUnicode=true&amp;characterEncoding=UTF-8&amp;serverTimezone=UTC"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
</bean> <!--sqlSessionFactory-->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="datasource"/>
<!--绑定Mybatis配置文件-->
<property name="configLocation" value="classpath:mybatis-config.xml"/>
<property name="mapperLocations" value="classpath:cn/lkx/mapper/UserMapper.xml"/>
</bean> <!--SqlSessionTemplate:我们使用的sqlSession-->
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
<!--只能使用构造器注入sqlSessionFactory ,源码中没有set-->
<constructor-arg index="0" ref="sqlSessionFactory"/>
</bean> <bean id="userMapper" class="cn.lkx.mapper.impl.UserMapperImpl">
<property name="sqlSessionTemplate" ref="sqlSession"/>
</bean>
</beans>

Spring-MyBatis的配置文件的更多相关文章

  1. SpringMVC Spring MyBatis整合配置文件

    1.spring管理SqlSessionFactory.mapper 1)在classpath下创建mybatis/sqlMapConfig.xml <?xml version="1. ...

  2. SpringMVC+Spring+Mybatis -- 集成之旅

    准备 首先介绍一下,我的工具使用的是STS, 需要的童鞋可以到官网下载:http://spring.io/tools/sts/all 使用STS是因为她集成了Maven进行 “包“ 管理以及自带 We ...

  3. 搭建spring+mybatis+struts2环境的配置文件

    1.web.xml配置 <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi=& ...

  4. Spring mybatis源码篇章-sql mapper配置文件绑定mapper class类

    前言:通过阅读源码对实现机制进行了解有利于陶冶情操,承接前文Spring mybatis源码篇章-MybatisDAO文件解析(二) 背景知识 MappedStatement是mybatis操作sql ...

  5. spring和mybatis整合配置文件

    查看所有springmvc  spring  mybatis配置文件见下链接: https://my.oschina.net/sherwayne/blog/262616 <?xml versio ...

  6. Spring,SpringMVC,MyBatis,SSM配置文件比较

    Spring配置文件: applicationContext.xml applicationContext.xml是Spring的核心配置文件 IOC/DI,AOP相关配置都是在这个文件中 Sprin ...

  7. Idea SpringMVC+Spring+MyBatis+Maven调整【转】

    Idea SpringMVC+Spring+MyBatis+Maven整合   创建项目 File-New Project 选中左侧的Maven,选中右侧上方的Create from archetyp ...

  8. SpringMVC+Spring+MyBatis+Maven调整【转】

    Idea SpringMVC+Spring+MyBatis+Maven整合   创建项目 File-New Project 选中左侧的Maven,选中右侧上方的Create from archetyp ...

  9. Spring+Mybatis基于注解整合Redis

    基于这段时间折腾redis遇到了各种问题,想着整理一下.本文主要介绍基于Spring+Mybatis以注解的形式整合Redis.废话少说,进入正题. 首先准备Redis,我下的是Windows版,下载 ...

  10. Maven+Spring MVC Spring Mybatis配置

    环境: Eclipse Neon JDK1.8.0 Tomcat8.0 先决条件: Eclipse先用maven向导创建web工程.参见本站之前随笔. 本机安装完成mysql5:新建用户xuxy03设 ...

随机推荐

  1. Java微信公众号服务器配置-验证Token

    一.填写服务器配置 首先我们需要在微信公众平台上填写服务器配置 重点内容    服务器地址URL(一定要外网能访问的到)        在我们提交配置的时候,微信会发送GET请求到URL上,      ...

  2. 对比redis的RDB、AOF模式的优缺点

    一.RDB模式 1.1 工作原理 RDB(Redis DataBase):基于时间的快照,其默认只保留当前最新的一次快照,特点是执行速度比较快,缺点是可 能会丢失从上次快照到当前时间点之间未做快照的数 ...

  3. 关于Java多线程-interrupt()、interrupted()、isInterrupted()解释

    多线程先明白一个术语"中断状态",中断状态为true,线程中断. interrupt():就是通知中止线程的,使"中断状态"为true. isInterrupt ...

  4. .Net Core AOP之AuthorizeAttribute

    一.简介 在.net core 中Filter分为以下六大类: 1.AuthorizeAttribute(权限验证) 2.IResourceFilter(资源缓存) 3.IActionFilter(执 ...

  5. [题解]RQNOJ PID86 智捅马蜂窝

    链接:http://www.rqnoj.cn/problem/86 思路:单源点最短路 建图:首先根据父子关系连双向边,边权是距离/速度:再根据跳跃关系连单向边,边权是自由落体的时间(注意自由下落是一 ...

  6. 2021年企业bi工具推荐

    数据时代,商业智能工具对于企业了解复杂的大数据非常重要. 我们研究整理了国内外几十个商业智能BI工具,主要就其在功能.性能.价格.体验.安全等方面进行评测,希望帮助企业更好的进行BI产品选型. 一.t ...

  7. 用图帮你了解https的原理

    Http存在的问题 上过网的朋友都知道,网络是非常不安全的.尤其是公共场所很多免费的wifi,或许只是攻击者的一个诱饵.还有大家平时喜欢用的万能钥匙,等等.那我们平时上网可能会存在哪些风险呢? 泄密, ...

  8. Spring源码之六-onRefresh()方法

    Spring源码之六-onRefresh()方法 大家好,我是程序员田同学. 今天带大家解读Spirng源码之六的onRefresh()方法,这是refresh()的其中的一个方法,看似是一个空方法, ...

  9. ansible复习笔记_基础-从零到无

    --创建时间:2021年1月25日 --修改时间:2021年3月9日 --作者:飞翔的小胖猪 前言 该文档仅作为作者复习ansible使用,对格式和流程没有做过多的编排和概述.不喜勿喷. 基础 ans ...

  10. linux(Centos7)安装mysql

    查看系统环境 [root@localhost html]# cat /etc/redhat-release CentOS Linux release 7.9.2009 (Core) CentOS 7 ...