<?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. kebernet--新手填坑

    1.安装好kubernet之后,新建rc后,里面的容器一直ImagePullBackOff ,镜像无法拉取: ----需要配置docker镜像为国内镜像,记得在各个Node上都要配置!!! vim / ...

  2. 关于static

    static是静态的意思: static修饰的成员变量,在内存中存在于方法区中,只有一份,非静态的成员变量在堆中,每个对象中都有一份 public class Demo1 {    public st ...

  3. MySQL数据库授权与索引

    MySQL数据库授权与索引 目录 MySQL数据库授权与索引 一.数据库用户授权 1. 授予权限 2. 查看权限 3. 删除权限 4. 全部权限(all privileges) 二.MySQL索引 1 ...

  4. JQgrid实现全表单元格编辑

    1 jQuery("#baseWageDataValueGrid").jqGrid('setGridParam',{'cellEdit':true}); 2 3 //修改所有td ...

  5. jquery.form 兼容IE89文件上传

    导入部分 <script type="text/javascript" src="js/jquery-1.8.3.min.js" charset=&quo ...

  6. HTTPStatus(状态码返回)详情

    1xx(临时响应) 表示临时响应并需要请求者继续执行操作的状态代码. 代码 说明 100 (继续) 请求者应当继续提出请求. 服务器返回此代码表示已收到请求的第一部分,正在等待其余部分. 101 (切 ...

  7. 生成一个node项目

    生成一个node项目1.创建文件夹2.文件夹中右键->在此处打开命令窗口->文件夹中打开dos3.执行:npm init //一路回车,最后y4.安装插件: C:\www\nodejs\h ...

  8. Solution -「BZOJ #3786」星系探索

    \(\mathcal{Description}\)   Link.   给定一棵含 \(n\) 个点的有根树,点有点权,支持 \(q\) 次操作: 询问 \(u\) 到根的点权和: 修改 \(u\) ...

  9. kubernetes集群之Pod说能不能让我体面的消亡呀?

    kubernetes集群之Pod说能不能让我体面的消亡呀? 由于 Pod 所代表的是在集群中节点上运行的进程,当不再需要这些进程时允许其体面地终止. 1.如果 preStop 回调所需要的时间长于默认 ...

  10. SRv6规模部署,离不开测试技术保驾护航!

    什么是SRv6? SRv6技术就是采用现有的IPv6转发技术,通过扩展IPv6报文的头域,实现类似标签转发的处理.SRv6将一些IPv6地址定义成实例化的SID(Segment ID),每个SID有着 ...