spring boot 项目MyBatis-plus 配置:
application.yml中加入如下属性:
mybatis-plus: # 配置扫描xml mapper-locations: - classpath:mapper/*.xml # 实体扫描,多个package用逗号或者分号分隔 type-aliases-package: 实体类扫描的包位置pom配置:
<dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>1.1.1</version> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus</artifactId> <version>2.1.8</version> </dependency> public List<Sheet> sheetList() { EntityWrapper<Sheet> entityWrapper = new EntityWrapper<>(); Sheet sheet = new Sheet(); entityWrapper.setEntity(sheet); return service.selectList(entityWrapper); }mybatis-plus可调用的方法:
查询方式 说明setSqlSelect 设置 SELECT 查询字段where WHERE 语句,拼接 + WHERE 条件and AND 语句,拼接 + AND 字段=值andNew AND 语句,拼接 + AND (字段=值)or OR 语句,拼接 + OR 字段=值orNew OR 语句,拼接 + OR (字段=值)eq 等于=allEq 基于 map 内容等于=ne 不等于<>gt 大于>ge 大于等于>=lt 小于<le 小于等于<=like 模糊查询 LIKEnotLike 模糊查询 NOT LIKEin IN 查询notIn NOT IN 查询isNull NULL 值查询isNotNull IS NOT NULLgroupBy 分组 GROUP BYhaving HAVING 关键词orderBy 排序 ORDER BYorderAsc ASC 排序 ORDER BYorderDesc DESC 排序 ORDER BYexists EXISTS 条件语句notExists NOT EXISTS 条件语句between BETWEEN 条件语句notBetween NOT BETWEEN 条件语句addFilter 自由拼接 SQLlast 拼接在最后,例如:last("LIMIT 1")