StudentMapper.xml

    1. <?xml version="1.0" encoding="UTF-8" ?>
    2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3//EN"
    3. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
    4. <!--
    5. mapper:是个整体文件的大标签,用来开始和结束xml文件
    6. 属性: namespace指定命名空间(相当于包名)用来区分不同mapper.xml文件中相同的id属性
    7. -->
    8. <mapper namespace="zar">
    9. <!--
    10. 完成查询全部学生的功能
    11. 之前是List<Student> getAll();
    12. resultType:指定查询返回的结果集的类型,如果是集合则必须是泛型的类型
    13. parameterType: 如果有参数,则通过它来指定参数的类型
    14. -->
    15. <select id="getAll" resultType="org.pojo.Student">
    16. select * from student
    17. </select>
    18. </mapper>

    getAll

    UserMapper.xml中也有个getAll

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3//EN"
            "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
    <mapper namespace="us">
        <select id="getAll" resultType="org.pojo.Student">
            select * from student
        </select>
    </mapper>
    

    俩个getAll怎么区别?

    就是namespace