1:  mybatis-config.xml

<?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>
<!-- 全局别名设置,在映射文件中只需写别名,而不必写出整个类路径 -->
<typeAliases>
<typeAlias type="com.deppon.test04.entity.StudentEntity" alias="StudentEntity"/>
</typeAliases>
<mappers>
<mapper resource="StudentMapper.xml" /> <!-- 可以定义多个mapper>
</mappers>
</configuration>

2: StudentMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.deppon.test04.dao.StudentMapper">
<resultMap type="StudentEntity" id="studentResultMap">
<id property="studentID" column="STUDENT_ID"/>
<result property="studentName" column="STUDENT_NAME"/>
<result property="studentSex" column="STUDENT_SEX"/>
<result property="studentBirthday" column="STUDENT_BIRTHDAY"/>
</resultMap>
<!-- 查询学生,根据id -->
<select id="getStudent" parameterType="String" resultType="com.deppon.test04.entity.StudentEntity" resultMap="studentResultMap">
<![CDATA[
SELECT * from STUDENT_TBL ST
WHERE ST.STUDENT_ID = #{studentID}
]]>
</select>
<!-- 查询学生列表 -->
<select id="getStudentAll" resultType="com.deppon.test04.entity.StudentEntity" resultMap="studentResultMap">
<![CDATA[
SELECT * from STUDENT_TBL
]]>
</select>
</mapper>

3:  mysql.properties

jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/student_manager?user=root&password=root&useUnicode=true&characterEncoding=UTF-8

4: dispatcherServlet

 <mvc:annotation-driven />
<context:component-scan base-package="liming.maven.example" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/" />
<property name="suffix" value=".jsp" />
</bean>
<!-- 导入属性配置文件 -->
<context:property-placeholder location="classpath:mysql.properties" />
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
</bean>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="configLocation" value="classpath:mybatis-config.xml" />
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="studentMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
<property name="mapperInterface" value="com.deppon.test04.dao.StudentMapper" />
<property name="sqlSessionFactory" ref="sqlSessionFactory" />
</bean>

mybatis 学习三 关键文件解析的更多相关文章

  1. MyBatis学习02(配置解析)

    配置解析 核心配置文件 mybatis-config.xml 系统核心配置文件 MyBatis 的配置文件包含了会深深影响 MyBatis 行为的设置和属性信息. 能配置的内容如下: configur ...

  2. MyBatis学习(三)---MyBatis和Spring整合

    想要了解MyBatis基础的朋友可以通过传送门: MyBatis学习(一)---配置文件,Mapper接口和动态SQL http://www.cnblogs.com/ghq120/p/8322302. ...

  3. Mybatis基础学习(三)—映射文件

    一.输入映射 1.parameterType     指定输入参数的Java类,可以使用别名或者类的全限定名.它也可以接受基本数据类型.POJO对象.HashMap.   (1)基本数据类型   (2 ...

  4. MyBatis笔记03------XXXMapper.xml文件解析

    SQL映射文件的配置解析 当我们写好mapper(dao)层接口时,然后在对应的XXXMapper.xml文件中写业务逻辑对应的SQL映射语句,通过这个文件中可以实现CRU操作,那么下面说明如何编写这 ...

  5. Mybatis学习4——核心文件sqlMapperConfig.xml属性

    1.外部文件jdbc.properties jdbc.driver=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://localhost:3306/mybatis ...

  6. Mybatis学习--Mapper XML文件

    学习笔记,选自Mybatis官方中文文档:http://www.mybatis.org/mybatis-3/zh/sqlmap-xml.html#insert_update_and_delete My ...

  7. MyBatis学习(三)

    前言 感觉学习进度还是比较慢啊,一整天的学习效率不是很高,一会看电视,一会喝茶,对自己的要求不严格...今天就说说关联表数据的插入以及别名的使用. 正文 1.关联插入 之前,我在数据库中已经创建了一张 ...

  8. Android学习----AndroidManifest.xml文件解析

    一个Android应用程序的结构: 一.关于AndroidManifest.xml AndroidManifest.xml 是每个android程序中必须的文件.它位于整个项目的根目录,描述了pack ...

  9. mybatis学习三

    Mybatis与pageHelper分页:    分页分为假分页和真分页对应的专业术语叫做逻辑分页和物理分页    逻辑分页:将所有的数据从数据库查询出来,根据需求截取符合要求的数据返回,方便统一但效 ...

随机推荐

  1. Ubuntu或Linux搭建网站环境常见问题详解

    本屌丝常见的问题已经全部记录如下,如大家有其他问题欢迎随时跟我进行交流. 1.无法进行软件源安装  提示信息:Package has no installation candidate 具体信息如下: ...

  2. mongodb 的安装(Centor OS )

    1.下载地址 wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.4.2.tgz 2.解压.配置 tar zxvf mongodb ...

  3. EntityFramework 学习 一 Colored Entity in Entity Framework 5.0

    You can change the color of an entity in the designer so that it would be easy to see related groups ...

  4. js字符串转dom

    function parse2dom(str){ var div = document.createElement("div"); if(typeof str == "s ...

  5. ansible安装nginx

    ansible安装nginx(实现回滚发布功能:下一篇博客.没想到写长了) 一.准备工作 1.准备两台机器 sai: 192.168.131.132  ——> ansible的服务端 luojy ...

  6. [Kafka] - Kafka内核理解:消息存储机制

    一个Topic分为多个Partition来进行数据管理,一个Partition中的数据是有序.不可变的,使用偏移量(offset)唯一标识一条数据,是一个long类型的数据 Partition接收到p ...

  7. Qt5 窗口内的控件随窗口大小自动变化

    http://www.bubuko.com/infodetail-827151.html 讲的很详细

  8. Flask download file vs django download file

    Only difference is make_response and httpresponse. FLASK VERSION: from flask import make_response @a ...

  9. poj2263 zoj1952 Heavy Cargo(floyd||spfa)

    这道题数据范围小,方法比较多.我用floyd和spfa分别写了一下,spfa明显有时间优势. 一个小技巧在于:把城市名称对应到数字序号,处理是用数字. 方法一:spfa #include<ios ...

  10. stl_hash_set.h

    stl_hash_set.h // Filename: stl_hash_set.h // Comment By: 凝霜 // E-mail: mdl2009@vip.qq.com // Blog: ...