MyBatis实现Mapper配置并查询数据
MyBatis:SQL语句都写在Mapper配置文件中,Mappers 标签就是用来配置需要加载的 SQL 映射配置文件路径的。Mappers标签下有许多mapper标签,每一个 mapper 标签中配置的都是一个独立的映射配置文件的路径。
配置:
<!-- mapper配置 -->
<mappers>
<mapper class="mapper.UserMapper"/>
</mappers>
xml使用mapper:
/** * 通过用户id查询用户年龄 * @param id 用户id * @return 用户年龄 */ Integer selectUserAgeById(Integer id);
select-resultType
<select id="selectUserById" resultMap=""> SELECT * FROM user WHERE id = #{id} </select>
浙公网安备 33010602011771号