一、创建主配置文件(SqlMapConfig.xml)
1.在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">
2.主配置文件中加入数据库环境,配置数据库连接池
<configuration>
<!--加载Oracle数据库配置文件-->
<properties resource="jdbc.properties"/>
<!-- 配置Oracle环境-->
<environments default="Oracle">
<environment id="Oracle">
<transactionManager type="JDBC"></transactionManager>
<!--配置数据源(连接池)-->
<dataSource type="POOLED">
<property name="driver" value="${driver}"/>
<property name="url" value="${url}"/>
<property name="username" value="${username}"/>
<property name="password" value="${password}"/>
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="com/seecen/Dao/StudentMapper.xml"/>
<mapper resource="com/seecen/Dao/TeacherMapper.xml"/>
</mappers>
</configuration>
3.mapper文件的配置
<mapper namespace="com.mappers.studentMappers" >
<!--增加-->
<select id="queryAllStudent" resultType="com.entity.Student">
select * from tblstudent
</select>
</mapper>