Mybatis之配置文件
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&useUnicode=true&characterEncoding=utf8&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之配置文件的更多相关文章
- 四、MyBatis主配置文件
//备注:该博客引自:http://limingnihao.iteye.com/blog/1060764 在定义sqlSessionFactory时需要指定MyBatis主配置文件: Xml代码 收藏 ...
- mybatis代码生成器配置文件详解
mybatis代码生成器配置文件详解 更多详见 http://generator.sturgeon.mopaas.com/index.html http://generator.sturgeon.mo ...
- 【Mybatis】配置文件加载属性
Mybatis将按照下面的顺序来加载属性: 1.在properties文本定义的属性首先被读取, 2.然后读取Mybatis的配置文件sqlConfig.xml配置文件中properties标签属性 ...
- Mybatis主配置文件常见使用讲解
在开发中我们通常将Mybatis中配置文件分两种,主配置文件与和dao对应的映射文件. 其实最后mybatis解析的还是一个主配置文件. 而映射文件会通过我们配置<mappers>属性,或 ...
- 详解mybatis映射配置文件
一 mybatis 映射文件结构 mybatis映射配置文件存在如下顶级元素,且这些元素按照如下顺序被定义. cache – 给定命名空间的缓存配置. cache-ref – 其他命名空间缓存配置的 ...
- MyBatis学习总结(二)——MyBatis核心配置文件与输入输出映射
在上一章中我们学习了<MyBatis学习总结(一)——ORM概要与MyBatis快速起步>,这一章主要是介绍MyBatis核心配置文件.使用接口+XML实现完整数据访问.输入参数映射与输出 ...
- mybatis xml配置文件模版
mybatis xml配置文件模版 1.mybatis核心配置文件书写(SqlMapConfig.xml) <?xml version="1.0" encoding=&quo ...
- Mybatis学习(3)关于mybatis全局配置文件SqlMapConfig.xml
比如针对我这个项目的mybatis全局配置文件SqlMapConfig.xml做一些说明: <?xml version="1.0" encoding="UTF-8& ...
- MyBatis核心配置文件详解
------------------------siwuxie095 MyBatis 核心配置文件详解 1.核心 ...
- mybatis的配置文件中<selectKey>标签问题
1.mybatis的配置文件中,使用sequence生成主键 未执行add方法之前,主键未生成(null):刚执行add之后,主键即生成(212) 这里的重点是,一旦执行add方法,配置文件中的sel ...
随机推荐
- JAVA中 PDF文件转成TIFF文件的2种方式
由于在工作中使用到了PDF->TIFF的技术,所以稍微研究了一下实现方式,通过资料查阅,暂时发现了2种方式,2种方式有所区别:第一种方式转化后的tiff文件是黑白的,第二种方式转化后的tiff文 ...
- 连接数据库 - (mysql-thinkphp) (2)
1.现在conf里面写好选择的数据库 选择好了以后 2.在index里面输入 查询mysql数据库里面的表tables_priv的所有数据 public function index() { $res ...
- firewalld学习-zone的使用和配置
原文地址:http://www.excelib.com/article/290/show zone文件标签名词解释 target:目标,这个前面学生也已经给大家介绍过了,可以理解为默认行为,有四个可选 ...
- Phoenix与HBase集成进行数据分析
安装好Phoenix后配置环境变量 export PHOENIX_PATH=/opt/cloudera/parcels/APACHE_PHOENIX-4.14.0-cdh5.14.2.p0.3expo ...
- STM32F103 USB虚拟串口 驱动例程移植
1)驱动下载及安装.目前ST公司支持WIN7版本号为:VCP_V1.3.1_Setup.exe (在官网上搜索stsw-stm32102即是了):先安装驱动后再插入USB不然安装不成功. 2)固件下载 ...
- python里的def 方法中->代表什么意思?
功能注释 函数注释是关于用户定义函数使用的类型的完全可选元数据信息(请参阅PEP 3107和 PEP 484了解更多信息). 注释__annotations__ 作为字典存储在函数的属性中,对函数的任 ...
- GoJS API学习
var node = {}; node["key"] = "节点Key"; node["loc"] = "0 0";// ...
- 自己写个tween
public Vector3 begin,end;//起始终止坐标 public float BtoE_time;//用时 float timer,lerp;//计时器和进度值 void Update ...
- Netty 模型
Demo代码 使用Maven的话请在pom.xml中注入netty依赖 <!-- https://mvnrepository.com/artifact/io.netty/netty-all -- ...
- HIVE ROW_NUMBER()函数去重
SELECT * FROM( SELECT *,ROW_NUMBER() OVER(PARTITION BY a.claimno ORDER BY b.financiancedate DESC) n ...