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>
<environments default="Mybatis_a"> <environment id="Mybatis_a">
<transactionManager type="jdbc"></transactionManager>
<dataSource type="pooled">
<property name="driver" value="com.mysql.cj.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/mybatis?serverTimezone=Asia/Shanghai&amp;useUnicode=true&amp;characterEncoding=utf8&amp;useSSL=true"/>
<property name="username" value="root"/>
<property name="password" value="wpy581"/>
</dataSource>
</environment> </environments> <!--注册-->
<mappers>
<mapper resource="cn/scitc/Mapper/StudentMapper.xml"/>
<mapper resource="cn/scitc/Mapper/TeacherMapper.xml"/>
</mappers> </configuration> //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="cn.scitc.Mapper.StudentMapper">
<resultMap id="Student" type="cn.scitc.pojo.Student">
<result property="id" column="id"/>
<result property="name" column="name"/>
<association property="teacher" column="tid" select="TselectInfo" javaType="cn.scitc.pojo.Teacher"/>
</resultMap> <select id="SelectInfo" resultMap="Student">
select * from student
</select> <select id="TselectInfo" resultType="cn.scitc.pojo.Teacher">
select * from teacher where id = #{id}
</select> <select id="SelectInfo1" resultMap="Student1">
select s.id sid,s.name sname,t.id tid,t.name tname from student s,teacher t where s.tid=t.id;
</select> <resultMap id="Student1" type="cn.scitc.pojo.Student">
<result property="id" column="sid"/>
<result property="name" column="sname"/>
<association property="teacher" javaType="cn.scitc.pojo.Teacher">
<result property="name" column="tname"/>
<result property="id" column="tid"/>
</association>
</resultMap> </mapper>

Mybatis之配置文件的更多相关文章

  1. 四、MyBatis主配置文件

    //备注:该博客引自:http://limingnihao.iteye.com/blog/1060764 在定义sqlSessionFactory时需要指定MyBatis主配置文件: Xml代码 收藏 ...

  2. mybatis代码生成器配置文件详解

    mybatis代码生成器配置文件详解 更多详见 http://generator.sturgeon.mopaas.com/index.html http://generator.sturgeon.mo ...

  3. 【Mybatis】配置文件加载属性

    Mybatis将按照下面的顺序来加载属性: 1.在properties文本定义的属性首先被读取, 2.然后读取Mybatis的配置文件sqlConfig.xml配置文件中properties标签属性 ...

  4. Mybatis主配置文件常见使用讲解

    在开发中我们通常将Mybatis中配置文件分两种,主配置文件与和dao对应的映射文件. 其实最后mybatis解析的还是一个主配置文件. 而映射文件会通过我们配置<mappers>属性,或 ...

  5. 详解mybatis映射配置文件

    一  mybatis 映射文件结构 mybatis映射配置文件存在如下顶级元素,且这些元素按照如下顺序被定义. cache – 给定命名空间的缓存配置. cache-ref – 其他命名空间缓存配置的 ...

  6. MyBatis学习总结(二)——MyBatis核心配置文件与输入输出映射

    在上一章中我们学习了<MyBatis学习总结(一)——ORM概要与MyBatis快速起步>,这一章主要是介绍MyBatis核心配置文件.使用接口+XML实现完整数据访问.输入参数映射与输出 ...

  7. mybatis xml配置文件模版

    mybatis xml配置文件模版 1.mybatis核心配置文件书写(SqlMapConfig.xml) <?xml version="1.0" encoding=&quo ...

  8. Mybatis学习(3)关于mybatis全局配置文件SqlMapConfig.xml

    比如针对我这个项目的mybatis全局配置文件SqlMapConfig.xml做一些说明: <?xml version="1.0" encoding="UTF-8& ...

  9. MyBatis核心配置文件详解

    ------------------------siwuxie095                                     MyBatis 核心配置文件详解         1.核心 ...

  10. mybatis的配置文件中<selectKey>标签问题

    1.mybatis的配置文件中,使用sequence生成主键 未执行add方法之前,主键未生成(null):刚执行add之后,主键即生成(212) 这里的重点是,一旦执行add方法,配置文件中的sel ...

随机推荐

  1. I2S 总线学习:2-I2S驱动WM8978

    背景 为了了解I2S总线所对应的硬件设计,下文转载了<STM32:I2S驱动WM8978>. 以加深对I2S总线的了解. 正文 最近项目中使用STM32F4驱动音频IC:WM8978. 由 ...

  2. STM32学习笔记:创建工程模板

    STM32作为一类高级单片机,在应用中不容小觑. 所以本人从2018年1月1日开始对于STM32系列单片机的学习. 本人所持的型号为:STM32F429ZI-DISCOVERY,M4内核,封装类型为: ...

  3. day02-Python运维开发基础

    1. Number 数据类型 2. 容器数据类型-字符串 """ 语法: "字符串" % (值1,值2 ... ) 占位符: %d 整型占位符 %f ...

  4. DB2的简单操作

    转 最近在看db2,边读边写了一些,记下来,虽然写的乱七八糟.以备后用. 这些都写的很简单.我觉得也算是一些简单的操作吧,有些也是摘自别人的blog具体是引用哪的就不太记得了. 一.DB2两种注释写法 ...

  5. uboot如何启动内核

    2.7.1.uboot和内核到底是什么 2.7.1.1.uboot是一个裸机程序 (1)uboot的本质就是一个复杂点的裸机程序.和我们在ARM裸机全集中学习的每一个裸机程序并没有本质区别. 2.7. ...

  6. 15.Pythonic与python杂记

    switcher ={ :'sunday', :'monday', :'thuesday' } day = day_name=switcher.get(day,'Unknow') print(day_ ...

  7. 使用python将请求的requests headers参数格式化方法

    import json # 使用三引号将浏览器复制出来的requests headers参数赋值给一个变量 headers = """ Host: zhan.qq.com ...

  8. Spark Storage 模块

    http://jerryshao.me/architecture/2013/10/08/spark-storage-module-analysis/ 大神写的太好了,我就不重复造轮子了. Spark ...

  9. 盘姬工具箱WV1.10

    ========================================================================== {盘姬工具箱CruiserEXPforWin版是一 ...

  10. LCD驱动详解

    参考文档:<液晶屏.pdf><S3C2440用户手册><JZ2440-V3原理图>   frame buffer: 显存,用于存放LCD显示数据:frame buf ...