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. LeetCode242 有效的字母异位词(Java字符数组排序&自定义排序记录)

    题目: 给定两个字符串 s 和 t ,编写一个函数来判断 t 是否是 s 的字母异位词.   示例 1: 输入: s = "anagram", t = "nagaram& ...

  2. fuseki远程访问方法

    ./fuseki-server启动服务后,我们的服务只能是localhost访问,无法被其他人访问,那么 要怎么修改呢.很简单,把apche-jena-fuseki-3.10.0/run 下面的shi ...

  3. 2-10 就业课(2.0)-oozie:9、oozie与hue的整合,以及整合后执行MR任务

    5.hue整合oozie 第一步:停止oozie与hue的进程 通过命令停止oozie与hue的进程,准备修改oozie与hue的配置文件 第二步:修改oozie的配置文件(老版本的bug,新版本已经 ...

  4. centos安装sass环境必看

    首先了解一下  sass是什么?! sass号称“世界上最成熟.最稳定.最强大的专业级css扩展语言” ,sass基于于Ruby语言开发而成,因此安装sass前需要安装Ruby, 1.安装ruby y ...

  5. 如何让Dev支持c++11特性

    1.点击工具选择编译选项 2.在编译时加入以下命令点击之后再将-std=c++11加入,点击确定就ok了

  6. VC 插入excel

    CString ePath,iPath; m_ePath.GetWindowText(ePath); m_iPath.GetWindowText(iPath); _Application app; W ...

  7. DEDECMS打开网站后台系统首页卡解决方法

    找到根目录下(一般是dede) templets文件夹下找到index_body.htm文件,将第25行至第41行部分注释或删除 保存文件,然后再打开后台,就不会有这个问题了.

  8. R语言 线性回归分析实例 《回归分析与线性统计模型》page72

    y,X1,X2,X3 分别表示第 t 年各项税收收入(亿元),某国生产总值GDP(亿元),财政支出(亿元)和商品零售价格指数(%). (1) 建立线性模型: ① 自己编写函数: > librar ...

  9. 杂记 -- 关于ref、kepp-alive、nextTick、fetch

    1.ref:定义一个普通的dom节点或一个vue的组件实例对象 定义方法: <div class="page1"> <button @click="li ...

  10. Erlang/Elixir精选-第5期(20200106)

    The forgotten ideas in computer science-Joe Armestrong 在2020年的第一期里面,一起回顾2018年Joe的 The forgotten idea ...