Two files:
1), a global profile: mybatis-config.xml ; some global guidance mybatis correct operation of the set ;
2), the SQL mapping file: EmployeeDao.xml ; is equivalent to a description of the realization of the interface Dao
detail:
1), acquired a proxy object interface; mybatis automatically created ;
2), SqlSessionFactory and the SqlSession;
SqlSessionFactory SqlSession create objects, Factory's only new one on the line
SqlSession: the equivalent of a database connection and interact, and a session database, you should create a new sqlSession;
Global configuration file: 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="development">
<environment id="development">
<transactionManager type="JDBC"/>
<!-- 配置连接池 -->
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/mybatis_0325"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
</dataSource>
</environment>
</environments>
<!-- mappers中注册我们所有写的dao接口的实现文件 -->
<mappers>
<!--resource:表示从类路径下找资源 -->
<mapper resource="EmployeeDao.xml"/>
</mappers>
</configuration>