1 <!--根据ID查询用户--> 2 <select id="getUserById" parameterType="int" resultType="User"> 3 select id,name,pwd as password from mybatis.user where id=#{id} 4 </select>
1 <resultMap id="UserMap" type="User"> 2 <!-- column是数据库表的列名 , property是对应实体类的属性名 --> 3 <!--<id column="id" property="id"/>--> 4 <!--<result column="name" property="name"/>--> 5 <result column="pwd" property="password"/> 6 </resultMap> 7 8 <!--根据ID查询用户--> 9 <select id="getUserById" parameterType="int" resultMap="UserMap"> 10 select * from mybatis.user where id=#{id} 11 </select>
原文:https://www.cnblogs.com/zhihaospace/p/12297579.html