SpringBoot MyBatis |
您所在的位置:网站首页 › spring集成mybatis自动commit › SpringBoot MyBatis |
MyBatis-Plus (opens new window)(简称 MP)是一个 MyBatis的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。 在 SpringBoot 项目的 pom.xml 中添加 Mybatis-plus 依赖 com.baomidou mybatis-plus-boot-starter 3.5.3.1 复制代码2 Mybatis-plus 的基本使用 在项目中的 UserMapper,java 中 继承 BaseMapper import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.biglead.demo.pojo.UserInfo; import org.mybatis.spring.annotation.MapperScan; import java.util.List; @MapperScan public interface UserMapper extends BaseMapper { List selectList(); /** * 分页查询用户 * @return */ List selectPage(); } 复制代码BaseMapper 是 Mybatis-plus 中提供的一个基类,其中封装了基础的增删改查的功能 : public interface BaseMapper extends Mapper { //插入 int insert(T entity); //通过主键删除 int deleteById(Serializable id); //通过Map字段对应值删除 int deleteByMap(@Param("cm") Map columnMap); //通过条件Wrapper删除 int delete(@Param("ew") Wrapper wrapper); //批量删除 int deleteBatchIds(@Param("coll") Collection |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |