每个基于Mybatis应用都是以一个SqlSessionFactory实例为中心。SqlSessionFactory实例可以由SqlSessionFactoryBuild获得,而SqlSessionFactoryBuild可以以一个xml配置文件(Configuration.xml)构建出SqlSessionFactory实例。
Configuration.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> //...... </configuration>
</configuration>主要有以下几个标签:
- <databaseIdProvider>
- <environments>
- <mappers>
- <objectFactory>
- <objectWrapperFactory>
- <plugins>
- <properties>
- <reflectorFactory>
- <settings>
- <typeAliases>
- <typeHandlers>
注意:mybatis全局配置文件的标签是有顺序限制的。
properties?, settings?, typeAliases?, typeHandlers?, objectFactory?, objectWrapperFactory?, reflectorFactory?, plugins?, environments?, databaseIdProvider?, mappers?
一、