Spring boot+mybatis-plus新建项目
配置mybatis-plus依赖
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>LATEST</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>LATEST</version>
</dependency>
配置lombok
- 安装依赖
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
- 安装插件
mybatis-plus 的输出sql语句配置
mybatis-plus:
mapper-locations: mapper/*Mapper.xml
# configuration:
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mybatis-plus 的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.smp.cutfood.mapper.IngredientsInformationMapper">
</mapper>
mybatis-plus or和and的联用
Wrapper queryWrapper = new QueryWrapper<BaseIngredientsInformation>()
.select()
.eq("is_delete",false)
.and(wrapper->wrapper.eq("ingredients_num", ingredientsInformation.getIngredientsNum()).or().eq("ingredients_Name", ingredientsInformation.getIngredientsName()));
List<BaseIngredientsInformation> getListByNumOrName = ingredientsInformationMapper.selectList(queryWrapper);