Mapper excuse similar to DAO connector
The MyBatis framework creates an interface's dynamic proxy object based on the interface definition
Mapper interface development needs to follow 4 development specifications
The namesapce of the mapping file in mapper is the same as the classpath of the Mapper interface
The Mapper interface method name and the ID of each SQL defined in the Mapper mapping file are the same
The input parameter type of the Mapper interface method is the same as the type of paramenttype defined for each SQL in the mapper mapping file
The output parameter type of the Mapper interface method is the same as that of each SQL-defined Resulttype in the mapper mapping file
Mapper mapping file Usermapper.xml placed in the Mapper directory of resources
<?xml version="1.0"encoding="UTF-8"? ><!DOCTYPE mapperpublic"-//mybatis.org//dtd Mapper 3.0//en""HTTP://MYBATIS.ORG/DTD/MYBATIS-3-MAPPER.DTD"><!--namespace: namespaces, which are used to isolate SQL--><!--also has an important role in developing DAO with dynamic agents,1. The namespace must be consistent with the Mapper interface class path--><mappernamespace="Com.itheima.mybatis.mapper.UserMapper"> <!--query users by User ID--<!--2. The ID must match the Mapper interface method name-<!--3. The parametertype must be consistent with the interface method parameter type-<!--4. Resulttype must be consistent with the interface method return value type-<SelectId="Queryuserbyid"Parametertype="Integer"Resulttype="Com.itheima.mybatis.pojo.User">Select* fromUserwhereID =#{id}</Select></mapper>
Mapper Dynamic Agent Considerations