1.首先应当创建dao接口,用于定义对数据表的各种操作
package com.leo.dao;
import com.leo.entity.Card;
import java.util.List;
public interface ICardMapping {
List<Card> getAllCard();
}
2.创建对应dao接口的xml映射文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.leo.dao.ICardMapping">
<select id="getAllCard" resultType="com.leo.entity.Card">
select *
from card;
</select>
</mapper>
注意事项
- dao接口和映射xml文件的目录层级应当一致,比如:
-