第一步:搭建可以运行的springboot项目
第二步:DAO层代码如下
packagecom.xc.springboot.dao.mapper;importcom.xc.springboot.dao.domain.MusicInfo;importorg.apache.ibatis.annotations.Mapper;importorg.apache.ibatis.annotations.Param;importorg.apache.ibatis.annotations.ResultMap;importorg.apache.ibatis.annotations.Select;importorg.springframework.data.jpa.repository.JpaRepository;importorg.springframework.stereotype.Component;importorg.springframework.stereotype.Repository;importjava.util.List;
@Repository("musicInfoMapper")public interfaceMusicInfoMapper {/*前闭后开
取前5条数据
select * from table_name limit 0,5
查询第11到第15条数据
select * from table_name limit 10,5
limit关键字的用法:
LIMIT [offset,] rows
offset指定要返回的第一行的偏移量,rows第二个指定返回行的最大数目。初始行的偏移量是0(不是1)。*/
//分页查询的方法
@ResultMap("BaseResultMap")
@Select("select * from music_i