1.XML映射文件的名称与Mapper接口名称一致,并且将XML映射文件和Mapper接口放置在相同包下(同包同名)。
2.XML映射文件的namespace属性为Mapper接口全限定名一致。
3.XML映射文件中的sql语句的id与Mapper接口中的方法名一致,并保持返回类型一致。
新建
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="">
<select id="" resultType="">
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.t0.maybatisc.mapper.EmpMapper">
<select id="com.t0.maybatisc.mapper.EmpMapper.list" resultType="com.t0.maybatisc.pojo.Emp">
select * from emp where name like concat('%',#{name},'%')
and gender = #{gender} and entrydate between #{begin} and #{end} order by update_time desc
</select>
</mapper>
安装插件
快速定位