1、基本介绍:
mybatis的核心配置文件(mybatis-config.xml),比如配置jdbc连接信息,注册mapper等等,我们需要对这个配置文件有详细的了解。
官网地址有详细介绍 mybatis -- MyBatis 3 | 配置
2、properties属性
在通常的情况下,我们会将jdbc的配置信息,写在一个外部文件,然后引入到mybatis-config.xml文件中
示例:
1、在resorces下新建file, jdbc.properties , 配置以下键值对

jdbc.user=root
jdbc.password=
jdbc.url=jdbc:mysql://localhost:3306/mybatisdb
jdbc.driver=com.mysql.jdbc.Driver
3、在myBatis.config.xml配置以下

3、settings属性

4、typeAliases 别名处理器
使用这个别名处理器,我们可以将一些名字很长的类,给他一个简洁的名字。
1、在mybatis.config.xml中配置 , 注意需要在<properties>标签之后配置
XML
<typeAliases>
<typeAlias type="com.bin.mybatis.entity.Monster" alias="Monster"/>
</typeAliases>
2、在mapper.xml使用

3、测试成功!
4、如果一个包下有很多的类,我们可以直接给包取别名,这样该包下面的所有类名,就可以直接使用
XML
<typeAliases>
<package name="com.bin.mybatis.entity"/>
<!-- <typeAlias type="com.bin.mybatis.entity.Monster" alias="Monster"/>-->
</typeAliases>
别名就是类名!!!!
5、typeHandler类型转换器
typeHandler用于java类型和jdbc类型(mysql字段)映射
Mybatis的映射基本已经满足,基本不太需要重新定义
6、<mappers>属性 (即在mybatis-config.xml配置映射器)
