SpringBoot 2.7.18 集成 Mybatis Plus + Druid
mybatis-plus
在mybatis
的基础上只做增强不做改变,因此只需把mybatis
的依赖换成mybatis-plus
的依赖
一并附上 Mybatis 和 Mybatis Plus 的使用区别
使用mybatisplus的步骤
- 导入mp的启动器
- 编写application.yml文件,配置数据源,打印日志
- 编写mapper接口,Mapper接口需要基础BaseMapper接口,BaseMapper接口需要指定操作的是哪个实体类。
- 在启动类中扫描的Mapper包
- 测试使用
Pom 依赖
Mybatis
<!-- 统一管理 jar 包版本 -->
<properties>
<druid-boot.version>1.1.10</druid-boot.version>
<mybatis-boot.version>2.1.0</mybatis-boot.version>
<mysql-connector.version>8.0.16</mysql-connector.version>
<mssql-jdbc.version>8.2.2.jre8</mssql-jdbc.version>
<oracle-jdbc.version>19.3.0.0</oracle-jdbc.version>
<pagehelper-starter.version>1.2.10</pagehelper-starter.version>
</properties>
<!--子模块继承之后,锁定版本+子模块不用写 groupid 和 version -->
<dependencyManagement>
<dependencies>
<!-- mybatis + druid + mysql + mssql-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid-boot.version}</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis-boot.version}</version>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>${pagehelper-starter.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-connector.version}</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>${mssql-jdbc.version}</version>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>${oracle-jdbc.version}</version>
</dependency>
<!-- mybatis + druid + mysql + mssql-->
</dependencies>
</dependencyManagement>
Mybatis Plus
使用框架自带的分布控件,如果使用 pagehelper
会报 JSqlParser
的版本冲突,根据情况排除 pagehelper
版本(不推荐)。
<!-- 统一管理 jar 包版本 -->
<properties>
<druid-boot.version>1.2.23</druid-boot.version>
<mybatis-plus.version>3.5.7</mybatis-plus.version>
<mysql-connector.version>8.0.33</mysql-connector.version>
<mssql-jdbc.version>8.2.2.jre8</mssql-jdbc.version>
<oracle-jdbc.version>19.3.0.0</oracle-jdbc.version>
</properties>
<!--子模块继承之后,锁定版本+子模块不用写 groupid 和 version -->
<dependencyManagement>
<dependencies>
<!-- mybatis plus + druid + mysql + mssql-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatis-plus.version}</version>
</dependency>
<!--分页-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-extension</artifactId>
<version>${mybatis-plus.version}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-annotation</artifactId>
<version>${mybatis-plus.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid-boot.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>${mysql-connector.version}</version>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>${mssql-jdbc.version}</version>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>${oracle-jdbc.version}</version>
</dependency>
<!-- mybatis plus + druid + mysql + mssql-->
</dependencies>
</dependencyManagement>
yml 配置
Mybatis
mybatis:
# 指定sql映射文件位置
mapper-locations: classpath*:mapper/*.xml
configuration:
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
type-handlers-package: com.vipsoft.base.handler # MySQL 8.0 用以mysql中json格式的字段,进行转换的自定义转换器,转换为实体类的JSONObject属性
Mybatis-Plus
mybatis-plus:
mapper-locations: classpath*:mapper/*Mapper.xml
global-config:
banner: true
db-config:
id-type: auto
where-strategy: not_empty
insert-strategy: not_empty
update-strategy: not_null
type-handlers-package: com.vipsoft.base.handler # MySQL 8.0 用以mysql中json格式的字段,进行转换的自定义转换器,转换为实体类的JSONObject属性
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
map-underscore-to-camel-case: true
jdbc-type-for-null: 'null'
call-setters-on-nulls: true
shrink-whitespaces-in-sql: true
druid
SpringBoot 配置多数据源
spring:
profiles:
active: dev
resources:
static-locations: classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,classpath:/web/,file:${cuwor.file.path}
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
#数据源基本配置
url: jdbc:mysql://192.168.1.100:3306/production_education?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=CONVERT_TO_NULL
username: root
password: root
#连接池的设置
druid:
initial-size: 5 #初始化时建立物理连接的个数
min-idle: 5 #最小连接池数量
max-active: 200 #最大连接池数量 maxIdle已经不再使用
max-wait: 60000 #获取连接时最大等待时间,单位毫秒
test-while-idle: true #申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效。
time-between-eviction-runs-millis: 60000 #既作为检测的间隔时间又作为testWhileIdel执行的依据
#销毁线程时检测当前连接的最后活动时间和当前时间差大于该值时,关闭当前连接
min-evictable-idle-time-millis: 30000
validation-query: select 'x' #用来检测连接是否有效的sql 必须是一个查询语句( mysql中为 select 'x' oracle中为 select 1 from dual)
test-on-borrow: false #申请连接时会执行validationQuery检测连接是否有效,开启会降低性能,默认为true
test-on-return: false #归还连接时会执行validationQuery检测连接是否有效,开启会降低性能,默认为true
#exception-sorter: true #当数据库抛出不可恢复的异常时,抛弃该连接
#pool-prepared-statements: true #是否缓存preparedStatement,mysql5.5+建议开启
max-pool-prepared-statement-per-connection-size: 20 #当值大于0时poolPreparedStatements会自动修改为true
filters: stat,wall #配置扩展插件
connection-properties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500 #通过connectProperties属性来打开mergeSql功能;慢SQL记录
use-global-data-source-stat: true #合并多个DruidDataSource的监控数据
#设置访问druid监控页的账号和密码,默认没有--放DrugConfig配置中
#stat-view-servlet.login-username: admin
#stat-view-servlet.login-password: admin
Config 配置
Druid 配置没有变化
package com.vipsoft.base.config;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@Configuration
public class DruidConfig {
@ConfigurationProperties(prefix = "spring.datasource")
@Bean
public DataSource druid(){
return new DruidDataSource();
}
//配置Druid的监控
//1、配置一个管理后台的Servlet
@Bean
public ServletRegistrationBean statViewServlet(){
ServletRegistrationBean bean = new ServletRegistrationBean(new StatViewServlet(), "/druid/*");
Map<String,String> initParams = new HashMap<>();
initParams.put("loginUsername","admin");
initParams.put("loginPassword","vipsoft");
initParams.put("resetEnable","false");
initParams.put("allow","");//默认就是允许所有访问
initParams.put("deny","192.168.15.21"); //IP黑名单(同时存在时,deny优先于allow)
bean.setInitParameters(initParams);
return bean;
}
//2、配置一个web监控的filter
@Bean
public FilterRegistrationBean webStatFilter(){
FilterRegistrationBean bean = new FilterRegistrationBean();
bean.setFilter(new WebStatFilter());
Map<String,String> initParams = new HashMap<>();
initParams.put("exclusions","*.js,*.css,/druid/*");
bean.setInitParameters(initParams);
bean.setUrlPatterns(Arrays.asList("/*"));
return bean;
}
}
Mybatis Plus 分页,需要添加 拦截器配置,否则分页不生效
如果需要使用到mybatis-plus的分页功能,必须存在一个配置类该配置类创建Mybatis的拦截器,这个拦截器的作用就是在你执行selectPage的方法的时候对sql进行拦截,然后拼接limit语句实现分页。
功能 | MP接口 |
---|---|
分页查询 | IPageselectPage(IPagepage) |
package com.vipsoft.base.config;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class MybatisPlusConfig {
/**
* 分页插件 -- 否则分页不生效
* @return
*/
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
return interceptor;
}
}
Mapper扫描
@MapperScan({"com.vipsoft.admin.mapper"}) 和 Mybatis 无区别
package com.vipsoft.admin;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@ComponentScan(basePackages = {"com.vipsoft"})
@SpringBootApplication
@MapperScan({"com.vipsoft.admin.mapper"})
public class VipSoftAdminApplication {
public static void main(String[] args) {
SpringApplication.run(VipSoftAdminApplication.class, args);
}
}
Entity
SysMenu
//@TableName("sys_menu") 默认会将 SysMenu 解析成 sys_menu 如果解析后不是正确的表名,需要通过 TableName进行指定,
public class SysMenu extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 菜单ID */
@TableId(value = "menu_id", type = IdType.ASSIGN_ID)
private Long menuId;
/** 菜单名称 */
@TableField(value = "menu_name")
private String menuName;
/** 父菜单名称 */
@TableField(exist = false) //非数据库字段,进行排除
private String parentName;
....省略
}
Mapper.xml
SysMenuMapper.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.vipsoft.admin.mapper.SysMenuMapper">
<resultMap type="com.vipsoft.admin.entity.SysMenu" id="SysMenuResult">
<id property="menuId" column="menu_id"/>
<result property="menuName" column="menu_name"/>
<result property="parentName" column="parent_name"/>
<result property="parentId" column="parent_id"/>
<result property="orderNum" column="order_num"/>
<result property="path" column="path"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<select id="listMenu" parameterType="com.vipsoft.admin.entity.SysMenu" resultMap="SysMenuResult">
select menu_id, menu_name, parent_id, order_num, create_time from sys_menu
<where>
<if test="menuName != null and menuName != ''">
AND menu_name like concat('%', #{menuName}, '%')
</if>
<if test="visible != null and visible != ''">
AND visible = #{visible}
</if>
<if test="status != null and status != ''">
AND status = #{status}
</if>
</where>
order by parent_id, order_num
</select>
<select id="listMenuPage" resultMap="SysMenuResult">
select menu_id, menu_name, parent_id, order_num, create_time from sys_menu
<where>
<if test="query.menuName != null and query.menuName != ''">
AND menu_name like concat('%', #{query.menuName}, '%')
</if>
<if test="query.visible != null and query.visible != ''">
AND visible = #{query.visible}
</if>
<if test="query.status != null and query.status != ''">
AND status = #{query.status}
</if>
</where>
order by parent_id, order_num
</select>
</mapper>
Mapper - SysMenuMapper
需要继承 BaseMapper
package com.vipsoft.admin.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vipsoft.admin.entity.SysMenu;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 菜单表 数据层
*/
public interface SysMenuMapper extends BaseMapper<SysMenu> {
List<SysMenu> listMenu(SysMenu menu);
IPage<SysMenu> listMenuPage(Page page, @Param("query") SysMenu menu);
}
Service
ISysMenuService
package com.vipsoft.admin.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.vipsoft.admin.entity.SysMenu;
import java.util.List;
/**
* 菜单 业务层
*
*/
public interface ISysMenuService
{
/**
* 列表查询(自定义SQL,分页)
*/
List<SysMenu> listMenu(SysMenu menu);
/**
* 列表查询(框架分页)
*/
IPage selectPage(SysMenu menu);
/**
* 列表查询(自定义SQL,分页)
*/
IPage listMenuPage(SysMenu menu);
}
SysMenuService
package com.vipsoft.admin.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.vipsoft.admin.entity.SysMenu;
import com.vipsoft.admin.mapper.SysMenuMapper;
import com.vipsoft.admin.service.ISysMenuService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.pagehelper.PageParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
* 菜单 业务层处理
*
* @author ruoyi
*/
@Service
public class SysMenuServiceImpl implements ISysMenuService {
@Autowired
private SysMenuMapper menuMapper;
/**
* 列表查询(自定义SQL,分页)
*/
@Override
public List<SysMenu> listMenu(SysMenu menu) {
return menuMapper.listMenu(new SysMenu());
}
/**
* 列表查询(框架分页)
*/
@Override
public IPage selectPage(SysMenu menu) {
Page page = new Page();
page.setCurrent(2);
page.setSize(10);
List<OrderItem> orderItems = new ArrayList<>();
orderItems.add(OrderItem.desc("menu_id"));
page.setOrders(orderItems);
Page pageList = menuMapper.selectPage(page, null);
return pageList;
}
/**
* 列表查询(自定义SQL,分页)
*/
@Override
public IPage listMenuPage(SysMenu menu) {
Page page = new Page();
page.setCurrent(2);
page.setSize(10);
List<OrderItem> orderItems = new ArrayList<>();
orderItems.add(OrderItem.desc("menu_id")); //先按 menu_id 排序,再按 mapper.xml 中的排(可以在查询输出的SQL中查看)
page.setOrders(orderItems);
IPage<SysMenu> pageList = menuMapper.listMenuPage(page, menu);
return pageList;
}
}
Controller
package com.vipsoft.admin.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.vipsoft.admin.entity.SysMenu;
import com.vipsoft.admin.service.ISysMenuService;
import com.vipsoft.base.core.ApiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 菜单信息
*/
@RestController
@RequestMapping("/menu")
public class SysMenuController {
@Autowired
private ISysMenuService menuService;
/**
* 获取菜单列表
*/
@GetMapping("/selectPage")
public ApiResult selectPage(SysMenu menu) {
IPage menus = menuService.selectPage(menu);
return new ApiResult(menus);
}
/**
* 获取菜单列表
*/
@GetMapping("/list")
public ApiResult listMenu(SysMenu menu) {
List<SysMenu> menus = menuService.listMenu(menu);
return new ApiResult(menus);
}
/**
* 获取菜单列表
*/
@GetMapping("/listMenuPage")
public ApiResult listMenuPage(SysMenu menu) {
IPage menus = menuService.listMenuPage(menu);
return new ApiResult(menus);
}
}
mybatis-plus为我们提供了一些标准数据层的CRUD功能,这些功能省去了我们自定义接口,也与我们自定义接口有部分差异,如下表:
功能 | 自定义接口 | MP接口 |
---|---|---|
新增 | boolean save(T t) | int insert(T t) |
删除 | boolean delete(int id) | int deleteById(Serializable id) |
修改 | boolean update(T t) | int updateById(T t) |
根据id查询 | T getById(int id) | T selectById(Serializable id) |
查询全部 | ListgetAll() | ListselectList() |
分页查询 | PageInfogetAll(int page, int size) | IPageselectPage(IPagepage) |
按条件查询 | ListgetAll(Condition condition) | IPageselectPage(WrapperqueryWrapper) |
条件构造器
/**
* 条件查询
*/
@Test
public void testFindByCondition(){
//QueryWrapper代表就是条件
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
//添加条件
//queryWrapper.lt() greater than 小于
//queryWrapper.le() greater equal 小于等于
//queryWrapper.ge() greater equal 大于等于
//queryWrapper.eq() equal 等于
//queryWrapper.gt() greater than 大于
queryWrapper.gt("age",18);
List<User> userList = userMapper.selectList(queryWrapper);
System.out.println("用户列表:"+ userList);
}
关键字 | 作用 | 示例 | 等价SQL |
---|---|---|---|
allEq | 匹配所有字段全部eq | .query().allEq({id:1,user_name:"老王",age:null}).list() | WHERE id =1 AND user_neme="老王" AND age IS NULL |
eq | 等于(==) | .lambdaQuery().eq(UserInfo::getId, 1) | WHERE id = 1 |
ne | 不等于(<>) | .lambdaQuery().ne( UserInfo::getId, 1) | WHERE id <> 1 |
gt | 大于(>) | .lambdaQuery().gt( UserInfo::getId, 1) | WHERE id > 1 |
ge | 大于等于(>=) | .lambdaQuery().ge( UserInfo::getId, 1) | WHERE id >= 1 |
lt | 小于(<) | .lambdaQuery().lt( UserInfo::getId, 1) | WHERE id < 1 |
le | 小于等于(<=) | .lambdaQuery().le( UserInfo::getId, 1) | WHERE id <= 1 |
between | 指定区间内 | .lambdaQuery().between( UserInfo::getId, 1,10) | WHERE (id BETWEEN 1 AND 10) |
notBetween | 指定区间外 | .lambdaQuery().notBetween( UserInfo::getId, 5,100) | WHERE (id NOT BETWEEN 5 AND 100) |
like | 字符串匹配 | .lambdaQuery().like( UserInfo::getUserName, “一行Java”) | WHERE (user_name LIKE "%一行Java%") |
notLike | 字符串不匹配 | .lambdaQuery().notLike( UserInfo::getUserName, “一行Java”) | WHERE (user_name NOT LIKE "%一行Java%") |
likeLeft | 字符串左匹配 | .lambdaQuery().likeLeft( UserInfo::getUserName, “一行Java”) | WHERE (user_name LIKE "%一行Java") |
likeRight | 字符串右匹配 | .lambdaQuery().likeRight( UserInfo::getUserName, “一行Java”) | WHERE (user_name LIKE "一行Java%") |
isNull | 等于null | .lambdaQuery().isNull(UserInfo::getUserName) | WHERE (user_name IS NULL) |
isNotNull | 不等于null | .lambdaQuery().isNotNull( UserInfo::getUserName) | WHERE (user_name IS NOT NULL) |
in | 包含 | .lambdaQuery().in(UserInfo::getId, 1, 2, 3) | WHERE (id IN (1, 2, 3)) |
notIn | 不包含 | .lambdaQuery().notIn(UserInfo::getId, 1, 2, 3) | WHERE (id NOT IN (1, 2, 3)) |
inSql | sql方式包含 | .lambdaQuery().inSql(UserInfo::getId, "1, 2, 3") | WHERE (id IN (1, 2, 3)) |
notInSql | sql方式不包含 | .lambdaQuery().notInSql(UserInfo::getId, "1, 2, 3") | WHERE (id NOT IN (1, 2, 3)) |
groupBy | 分组 | .select("source,count(id) as sum").groupBy("source").having("count(id) > {0}", 35); | GROUP BY source HAVING count(id) > 35 |
orderByAsc | 升序 | .lambdaQuery().orderByAsc(UserInfo::getSource) | ORDER BY source ASC |
orderByDesc | 降序 | .lambdaQuery().orderByDesc(UserInfo::getSource) | ORDER BY source DESC |
orderBy | 排序 | .lambdaQuery().orderBy(true, true, UserInfo::getSource) | ORDER BY source ASC |
having | having子句 | .select("source,count(id) as sum").groupBy("source").having("count(id) > {0}", 35); | GROUP BY source HAVING count(id) > 35 |
func | 自定义Consumer | .lambdaQuery().func(i -> {if (true) {i.eq(UserInfo::getId, 10);} else {i.eq(UserInfo::getId, 100); }}) | WHERE (id = 10) |
or | 多条件满足一个 | .lambdaQuery()..le(UserInfo::getId, 10) .or(i -> .eq(UserInfo::getUserName, "张三").ge(UserInfo::getId, 1005)) | WHERE (id <= 10 OR (user_name = "张三" AND id >= 1005)) |
and | 多条件同时满足 | .lambdaQuery().le(UserInfo::getId, 10) .and(i -> i.eq(UserInfo::getUserName, "一行Java 1")) | WHERE (id <= 10 AND (user_name = "一行Java 1")) |
nested | 指定条件用()嵌套 | .lambdaQuery().ge(UserInfo::getId, 10).nested(i -> i.eq(UserInfo::getUserName, "张三").or(m -> m.ge(UserInfo::getId, 1005))) | WHERE (id >= 10 AND (user_name = "张三" OR (id >= 1005))) |
apply | 拼接sql | .lambdaQuery().apply("id < {0}", 20) | WHERE (id < 20) |
last | 拼接语句在sql最后 | .lambdaQuery().apply("id < {0}", 20).last("limit 1") | WHERE (id < ?) limit 1 |
exists | 子句存在数据 | .lambdaQuery().exists("select id from user_info where id > 1000") | WHERE (EXISTS (select id from user_info where id > 1000)) |
notExists | 子句不存在数据 | .lambdaQuery().notExists("select id from user_info where id > 10000") | WHERE (NOT EXISTS (select id from user_info where id > 10000)) |
allEq
参数
condition
所有条件是否生效,默认是true;设置为false之后,设置的所有的条件都不会生效
params
Map参数;设置需要匹配的字段和对应的值
filter
用于设置需要过滤的字段
null2IsNull
是否忽略null值;默认是true,如果有需要匹配的字段是null,则会添加 is null的查询条件;如果设置为false,将会自动剔除所有值null的字段校验
本文来自博客园,作者:VipSoft 转载请注明原文链接:https://www.cnblogs.com/vipsoft/p/18489354