MybatisPlus重要知识点

文章目录

  • MybatisPlus重要知识点
  • 1、基本CRUD
    • 1.1、继承BaseMapper
    • 1.2、继承IService
  • 2、条件拼接
  • 3、常用注解
    • 3.1、@TableName()
    • 3.2、@TableId
    • 3.3、@TableField()
    • 3.4、@Version
    • 3.5、@EnumValue
    • 3.6、@TableLogic
  • 4、插件
    • 4.1、分页插件
    • 4.2、乐观锁
    • 4.3、通用枚举类
    • 4.4、自动生成代码

官网文档

代码地址

1、基本CRUD

1.1、继承BaseMapper

BaseMapper类如下所示:

public interface BaseMapper<T> extends Mapper<T> {/*** 插入一条记录** @param entity 实体对象*/int insert(T entity);/*** 根据 ID 删除** @param id 主键ID*/int deleteById(Serializable id);/*** 根据 columnMap 条件,删除记录** @param columnMap 表字段 map 对象*/int deleteByMap(@Param(Constants.COLUMN_MAP) Map<String, Object> columnMap);/*** 根据 entity 条件,删除记录** @param queryWrapper 实体对象封装操作类(可以为 null,里面的 entity 用于生成 where 语句)*/int delete(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper);/*** 删除(根据ID 批量删除)** @param idList 主键ID列表(不能为 null 以及 empty)*/int deleteBatchIds(@Param(Constants.COLLECTION) Collection<? extends Serializable> idList);/*** 根据 ID 修改** @param entity 实体对象*/int updateById(@Param(Constants.ENTITY) T entity);/*** 根据 whereEntity 条件,更新记录** @param entity        实体对象 (set 条件值,可以为 null)* @param updateWrapper 实体对象封装操作类(可以为 null,里面的 entity 用于生成 where 语句)*/int update(@Param(Constants.ENTITY) T entity, @Param(Constants.WRAPPER) Wrapper<T> updateWrapper);/*** 根据 ID 查询** @param id 主键ID*/T selectById(Serializable id);/*** 查询(根据ID 批量查询)** @param idList 主键ID列表(不能为 null 以及 empty)*/List<T> selectBatchIds(@Param(Constants.COLLECTION) Collection<? extends Serializable> idList);/*** 查询(根据 columnMap 条件)** @param columnMap 表字段 map 对象*/List<T> selectByMap(@Param(Constants.COLUMN_MAP) Map<String, Object> columnMap);/*** 根据 entity 条件,查询一条记录** @param queryWrapper 实体对象封装操作类(可以为 null)*/T selectOne(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper);/*** 根据 Wrapper 条件,查询总记录数** @param queryWrapper 实体对象封装操作类(可以为 null)*/Integer selectCount(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper);/*** 根据 entity 条件,查询全部记录** @param queryWrapper 实体对象封装操作类(可以为 null)*/List<T> selectList(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper);/*** 根据 Wrapper 条件,查询全部记录** @param queryWrapper 实体对象封装操作类(可以为 null)*/List<Map<String, Object>> selectMaps(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper);/*** 根据 Wrapper 条件,查询全部记录* <p>注意: 只返回第一个字段的值</p>** @param queryWrapper 实体对象封装操作类(可以为 null)*/List<Object> selectObjs(@Param(Constants.WRAPPER) Wrapper<T> queryWrapper);/*** 根据 entity 条件,查询全部记录(并翻页)** @param page         分页查询条件(可以为 RowBounds.DEFAULT)* @param queryWrapper 实体对象封装操作类(可以为 null)*/<E extends IPage<T>> E selectPage(E page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper);/*** 根据 Wrapper 条件,查询全部记录(并翻页)** @param page         分页查询条件* @param queryWrapper 实体对象封装操作类*/<E extends IPage<Map<String, Object>>> E selectMapsPage(E page, @Param(Constants.WRAPPER) Wrapper<T> queryWrapper);
}

1.2、继承IService

public interface IService<T> {/*** 默认批次提交数量*/int DEFAULT_BATCH_SIZE = 1000;/*** 插入一条记录(选择字段,策略插入)** @param entity 实体对象*/default boolean save(T entity) {return SqlHelper.retBool(getBaseMapper().insert(entity));}/*** 插入(批量)** @param entityList 实体对象集合*/@Transactional(rollbackFor = Exception.class)default boolean saveBatch(Collection<T> entityList) {return saveBatch(entityList, DEFAULT_BATCH_SIZE);}/*** 插入(批量)** @param entityList 实体对象集合* @param batchSize  插入批次数量*/boolean saveBatch(Collection<T> entityList, int batchSize);/*** 批量修改插入** @param entityList 实体对象集合*/@Transactional(rollbackFor = Exception.class)default boolean saveOrUpdateBatch(Collection<T> entityList) {return saveOrUpdateBatch(entityList, DEFAULT_BATCH_SIZE);}/*** 批量修改插入** @param entityList 实体对象集合* @param batchSize  每次的数量*/boolean saveOrUpdateBatch(Collection<T> entityList, int batchSize);/*** 根据 ID 删除** @param id 主键ID*/default boolean removeById(Serializable id) {return SqlHelper.retBool(getBaseMapper().deleteById(id));}/*** 根据 columnMap 条件,删除记录** @param columnMap 表字段 map 对象*/default boolean removeByMap(Map<String, Object> columnMap) {Assert.notEmpty(columnMap, "error: columnMap must not be empty");return SqlHelper.retBool(getBaseMapper().deleteByMap(columnMap));}/*** 根据 entity 条件,删除记录** @param queryWrapper 实体包装类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}*/default boolean remove(Wrapper<T> queryWrapper) {return SqlHelper.retBool(getBaseMapper().delete(queryWrapper));}/*** 删除(根据ID 批量删除)** @param idList 主键ID列表*/default boolean removeByIds(Collection<? extends Serializable> idList) {if (CollectionUtils.isEmpty(idList)) {return false;}return SqlHelper.retBool(getBaseMapper().deleteBatchIds(idList));}/*** 根据 ID 选择修改** @param entity 实体对象*/default boolean updateById(T entity) {return SqlHelper.retBool(getBaseMapper().updateById(entity));}/*** 根据 UpdateWrapper 条件,更新记录 需要设置sqlset** @param updateWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper}*/default boolean update(Wrapper<T> updateWrapper) {return update(null, updateWrapper);}/*** 根据 whereEntity 条件,更新记录** @param entity        实体对象* @param updateWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper}*/default boolean update(T entity, Wrapper<T> updateWrapper) {return SqlHelper.retBool(getBaseMapper().update(entity, updateWrapper));}/*** 根据ID 批量更新** @param entityList 实体对象集合*/@Transactional(rollbackFor = Exception.class)default boolean updateBatchById(Collection<T> entityList) {return updateBatchById(entityList, DEFAULT_BATCH_SIZE);}/*** 根据ID 批量更新** @param entityList 实体对象集合* @param batchSize  更新批次数量*/boolean updateBatchById(Collection<T> entityList, int batchSize);/*** TableId 注解存在更新记录,否插入一条记录** @param entity 实体对象*/boolean saveOrUpdate(T entity);/*** 根据 ID 查询** @param id 主键ID*/default T getById(Serializable id) {return getBaseMapper().selectById(id);}/*** 查询(根据ID 批量查询)** @param idList 主键ID列表*/default List<T> listByIds(Collection<? extends Serializable> idList) {return getBaseMapper().selectBatchIds(idList);}/*** 查询(根据 columnMap 条件)** @param columnMap 表字段 map 对象*/default List<T> listByMap(Map<String, Object> columnMap) {return getBaseMapper().selectByMap(columnMap);}/*** 根据 Wrapper,查询一条记录 <br/>* <p>结果集,如果是多个会抛出异常,随机取一条加上限制条件 wrapper.last("LIMIT 1")</p>** @param queryWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}*/default T getOne(Wrapper<T> queryWrapper) {return getOne(queryWrapper, true);}/*** 根据 Wrapper,查询一条记录** @param queryWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}* @param throwEx      有多个 result 是否抛出异常*/T getOne(Wrapper<T> queryWrapper, boolean throwEx);/*** 根据 Wrapper,查询一条记录** @param queryWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}*/Map<String, Object> getMap(Wrapper<T> queryWrapper);/*** 根据 Wrapper,查询一条记录** @param queryWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}* @param mapper       转换函数*/<V> V getObj(Wrapper<T> queryWrapper, Function<? super Object, V> mapper);/*** 查询总记录数** @see Wrappers#emptyWrapper()*/default int count() {return count(Wrappers.emptyWrapper());}/*** 根据 Wrapper 条件,查询总记录数** @param queryWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}*/default int count(Wrapper<T> queryWrapper) {return SqlHelper.retCount(getBaseMapper().selectCount(queryWrapper));}/*** 查询列表** @param queryWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}*/default List<T> list(Wrapper<T> queryWrapper) {return getBaseMapper().selectList(queryWrapper);}/*** 查询所有** @see Wrappers#emptyWrapper()*/default List<T> list() {return list(Wrappers.emptyWrapper());}/*** 翻页查询** @param page         翻页对象* @param queryWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}*/default <E extends IPage<T>> E page(E page, Wrapper<T> queryWrapper) {return getBaseMapper().selectPage(page, queryWrapper);}/*** 无条件翻页查询** @param page 翻页对象* @see Wrappers#emptyWrapper()*/default <E extends IPage<T>> E page(E page) {return page(page, Wrappers.emptyWrapper());}/*** 查询列表** @param queryWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}*/default List<Map<String, Object>> listMaps(Wrapper<T> queryWrapper) {return getBaseMapper().selectMaps(queryWrapper);}/*** 查询所有列表** @see Wrappers#emptyWrapper()*/default List<Map<String, Object>> listMaps() {return listMaps(Wrappers.emptyWrapper());}/*** 查询全部记录*/default List<Object> listObjs() {return listObjs(Function.identity());}/*** 查询全部记录** @param mapper 转换函数*/default <V> List<V> listObjs(Function<? super Object, V> mapper) {return listObjs(Wrappers.emptyWrapper(), mapper);}/*** 根据 Wrapper 条件,查询全部记录** @param queryWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}*/default List<Object> listObjs(Wrapper<T> queryWrapper) {return listObjs(queryWrapper, Function.identity());}/*** 根据 Wrapper 条件,查询全部记录** @param queryWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}* @param mapper       转换函数*/default <V> List<V> listObjs(Wrapper<T> queryWrapper, Function<? super Object, V> mapper) {return getBaseMapper().selectObjs(queryWrapper).stream().filter(Objects::nonNull).map(mapper).collect(Collectors.toList());}/*** 翻页查询** @param page         翻页对象* @param queryWrapper 实体对象封装操作类 {@link com.baomidou.mybatisplus.core.conditions.query.QueryWrapper}*/default <E extends IPage<Map<String, Object>>> E pageMaps(E page, Wrapper<T> queryWrapper) {return getBaseMapper().selectMapsPage(page, queryWrapper);}/*** 无条件翻页查询** @param page 翻页对象* @see Wrappers#emptyWrapper()*/default <E extends IPage<Map<String, Object>>> E pageMaps(E page) {return pageMaps(page, Wrappers.emptyWrapper());}/*** 获取对应 entity 的 BaseMapper** @return BaseMapper*/BaseMapper<T> getBaseMapper();/*** 获取 entity 的 class** @return {@link Class<T>}*/Class<T> getEntityClass();/*** 以下的方法使用介绍:** 一. 名称介绍* 1. 方法名带有 query 的为对数据的查询操作, 方法名带有 update 的为对数据的修改操作* 2. 方法名带有 lambda 的为内部方法入参 column 支持函数式的* 二. 支持介绍** 1. 方法名带有 query 的支持以 {@link ChainQuery} 内部的方法名结尾进行数据查询操作* 2. 方法名带有 update 的支持以 {@link ChainUpdate} 内部的方法名为结尾进行数据修改操作** 三. 使用示例,只用不带 lambda 的方法各展示一个例子,其他类推* 1. 根据条件获取一条数据: `query().eq("column", value).one()`* 2. 根据条件删除一条数据: `update().eq("column", value).remove()`**//*** 链式查询 普通** @return QueryWrapper 的包装类*/default QueryChainWrapper<T> query() {return ChainWrappers.queryChain(getBaseMapper());}/*** 链式查询 lambda 式* <p>注意:不支持 Kotlin </p>** @return LambdaQueryWrapper 的包装类*/default LambdaQueryChainWrapper<T> lambdaQuery() {return ChainWrappers.lambdaQueryChain(getBaseMapper());}/*** 链式查询 lambda 式* kotlin 使用** @return KtQueryWrapper 的包装类*/default KtQueryChainWrapper<T> ktQuery() {return ChainWrappers.ktQueryChain(getBaseMapper(), getEntityClass());}/*** 链式查询 lambda 式* kotlin 使用** @return KtQueryWrapper 的包装类*/default KtUpdateChainWrapper<T> ktUpdate() {return ChainWrappers.ktUpdateChain(getBaseMapper(), getEntityClass());}/*** 链式更改 普通** @return UpdateWrapper 的包装类*/default UpdateChainWrapper<T> update() {return ChainWrappers.updateChain(getBaseMapper());}/*** 链式更改 lambda 式* <p>注意:不支持 Kotlin </p>** @return LambdaUpdateWrapper 的包装类*/default LambdaUpdateChainWrapper<T> lambdaUpdate() {return ChainWrappers.lambdaUpdateChain(getBaseMapper());}/*** <p>* 根据updateWrapper尝试更新,否继续执行saveOrUpdate(T)方法* 此次修改主要是减少了此项业务代码的代码量(存在性验证之后的saveOrUpdate操作)* </p>** @param entity 实体对象*/default boolean saveOrUpdate(T entity, Wrapper<T> updateWrapper) {return update(entity, updateWrapper) || saveOrUpdate(entity);}
}

两种实现方式。

2、条件拼接

上面的两个实例可以看出,需要一个叫Wrapper的属性,该类就是拼接一些参数条件等。

常用类接口如下所示:

具体的方法不在这儿展示了。

展示一个使用demo吧

@SpringBootTest(classes = MybatisPlusStarter.class)
@RunWith(SpringRunner.class)
@Slf4j
public class SampleTest {@Autowiredprivate UserMapper userMapper;@Autowired@Qualifier(value = "userServiceImpl")private UserService userService;@Testpublic void testSelect() {System.out.println(("----- selectAll method test ------"));List<User> userList = userMapper.selectList(null);userList.forEach(System.out::println);}@Testpublic void testInsert() {System.out.println(("----- insert method test ------"));User user = new User();user.setAge(22);user.setEmail("1107@qq.com");user.setMyName("咸蛋超人");int insert = userMapper.insert(user);System.out.println("添加了:" + insert + "条数据!");}@Testpublic void testDeleteByMap() {Map<String, Object> columnMap = new HashMap<>(2);columnMap.put("name", "咸蛋超人");columnMap.put("age", "22");int result = userMapper.deleteByMap(columnMap);System.out.println("受影响行数:" + result);}@Testpublic void testUpdateById() {User user = new User(4L, "admin", 22);
//UPDATE user SET name=?, age=? WHERE id=?int result = userMapper.updateById(user);System.out.println("受影响行数:" + result);}@Testpublic void testServiceByID() {User byId = userService.getById(1);log.info("输出结果:{}", byId);}@Testpublic void testServiceByWrapper() {QueryWrapper<User> wrapper = new QueryWrapper();wrapper.like("my_name", "咸蛋%");List<User> list = userService.list(wrapper);log.info("testServiceByWrapper输出结果:{}", JSONObject.toJSONString(list));}@Testpublic void testDelete() {List<Integer> idList = new ArrayList<>();idList.add(1);idList.add(2);boolean b = userService.removeByIds(idList);}@Testpublic void testList() {List<User> list = userService.list();log.info("查询所有:{}", JSONObject.toJSONString(list));}@Testpublic void testQueryWrapper() {QueryWrapper<User> wrapper = new QueryWrapper();wrapper.select("uid as id", "my_name as myName")
//                .eq("age", 20).setEntity(new User()).inSql("uid", "select uid from t_user where uid <= 5");
/*        wrapper.select(User.class, x -> {String property = x.getProperty();return property.equals("name");}).eq("age", 20);*/
//        List<User> list = userService.listByIds(Arrays.asList(1,2,3));List<User> list = userService.list(wrapper);log.info("查询所有:{}", JSONObject.toJSONString(list));}@Testpublic void testUpdateWrapper() {UpdateWrapper<User> userUpdateWrapper = new UpdateWrapper<>();userUpdateWrapper.set("my_name", "迪迦奥特曼").ge("age", 10).and(consumer -> {consumer.eq("my_name", "咸蛋超人").isNotNull("email");});boolean update = userService.update(userUpdateWrapper);System.out.println(update);}/*** 一直报错 说lambda表达式解析失败。*/@Testpublic void testLambdaList() {LambdaQueryWrapper<User> userLambdaQueryWrapper = Wrappers.lambdaQuery();Predicate<TableFieldInfo> predicate = x -> x.getProperty().equals("myName");userLambdaQueryWrapper.select(User.class, predicate).eq(y -> y.getAge(), "20");List<User> list = userService.list(userLambdaQueryWrapper);log.info("查询所有:{}", JSONObject.toJSONString(list));}@Testpublic void testLambdaCondition() {String username = "迪迦奥特曼";Integer ageEnd = 30;Integer ageBegin = 10;LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<>();queryWrapper.select(User::getAge, User::getUid, User::getEmail, User::getMyName).like(StringUtils.isNotBlank(username), User::getMyName, username).ge(ageBegin != null, User::getAge, ageBegin).le(ageEnd != null, User::getAge, ageEnd);List<User> list = userService.list(queryWrapper);log.info("查询所有:{}", JSONObject.toJSONString(list));}@Testpublic void testMyMapperXml() {List<User> byId = userMapper.getById(1l);log.info("查询所有:{}", JSONObject.toJSONString(byId));}
}

3、常用注解

3.1、@TableName()

  • 描述:表名注解,标识实体类对应的表
  • 使用位置:实体类
属性 类型 必须指定 默认值 描述
value String “” 表名
schema String “” schema
keepGlobalPrefix boolean false 是否保持使用全局的 tablePrefix 的值(当全局 tablePrefix 生效时)
resultMap String “” xml 中 resultMap 的 id(用于满足特定类型的实体类对象绑定)
autoResultMap boolean false 是否自动构建 resultMap 并使用(如果设置 resultMap 则不会进行 resultMap 的自动构建与注入)
excludeProperty String[] {} 需要排除的属性名 @since 3.3.1

3.2、@TableId

  • 描述:主键注解
  • 使用位置:实体类主键字段
属性 类型 必须指定 默认值 描述
value String “” 主键字段名
type Enum IdType.NONE 指定主键类型

3.3、@TableField()

  • 描述:字段注解(非主键)
属性 类型 必须指定 默认值 描述
value String “” 数据库字段名
exist boolean true 是否为数据库表字段

3.4、@Version

  • 描述:乐观锁注解、标记 @Verison 在字段上

3.5、@EnumValue

  • 描述:普通枚举类注解(注解在枚举字段上)

3.6、@TableLogic

  • 描述:表字段逻辑处理注解(逻辑删除)
属性 类型 必须指定 默认值 描述
value String “” 逻辑未删除值
delval String “” 逻辑删除值

4、插件

    @Beanpublic MybatisPlusInterceptor innerInterceptor() {MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));//分页插件interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor()); //乐观锁插件return interceptor;}

4.1、分页插件

  • 配置类加入分页插件配置
  • 使用Page类进行分页

示例:基于自定义xml的形式:

    /*** 自定义xml分页查询*/@Testpublic void testMyMapperPageXml() {Page<User> userPage = userMapper.selectPageVo(new Page<>(1, 2), 1);log.info("分页查询查询所有:{}", JSONObject.toJSONString(userPage));}/**** @param page 分页对象,xml中可以从里面进行取值,传递参数 Page 即自动分页,必须放在第一位* @param age* @return*/Page<User> selectPageVo(@Param("page") Page<User> page, @Param("age") Integer age);

示例:基于mybatis plus的实现

/*** mybatis 使用分页插件*/
@Test
public void testSelectByPage() {System.out.println(("----- selectAll method test ------"));QueryWrapper<User> userQueryWrapper = new QueryWrapper<User>();userQueryWrapper.ge("uid", 1);IPage iPage = userMapper.selectMapsPage(new Page<>(1, 2), userQueryWrapper);List<User> userList = JSONObject.parseArray(JSONObject.toJSONString(iPage.getRecords()), User.class);log.info("分页查询返回:{}", JSON.toJSONString(iPage));log.info("返回对象:{}", JSON.toJSONString(userList));
}

4.2、乐观锁

  • 在乐观锁的字段上添加@Version注解
  • 在配置类中配置乐观锁

示例:

    @Versionprivate Integer version;调用代码:/*** mybatis plus 乐观锁插件进行实现,在对应的字段上添加@Version注解*/@Testpublic void mybatisPlusOptimisticLock() {Product product = productMapper.selectById(1);Product product1 = productMapper.selectById(1);product.setPrice(120);int update = productMapper.update(product, null);System.out.println("第一次修改数据条数为:" + update);if (update > 0) {product1 = productMapper.selectById(1);}product1.setPrice(70);int update1 = productMapper.update(product1, null);System.out.println("第二次修改数据条数为:" + update1);Product product3 = productMapper.selectById(1);System.out.println(product3);}

4.3、通用枚举类

  • 在枚举类中声明哪个字段保存在数据库
  • 修改配置文件,扫描枚举类的包

示例: @EnumValue声明哪个字段保存在数据库中

@Getter
public enum SexEnum {MALE(1, "男"),FEMALE(2, "女");@EnumValueprivate Integer sex;private String sexName;SexEnum(Integer sex, String sexName) {this.sex = sex;this.sexName = sexName;}
}另一个类引入枚举类即可。/*** 性别 1男 ;2女*/private SexEnum sex;
  type-enums-package: com.zgf.study.mybatisplus.enums #枚举类扫描包

4.4、自动生成代码

public class FastAutoGeneratorTest {public static void main(String[] args) {FastAutoGenerator.create("数据库url", "用户名", "密码").globalConfig(builder -> {builder.author("summit") // 设置作者//.enableSwagger() // 开启 swagger 模式.fileOverride() // 覆盖已生成文件.outputDir("D://mybatis_plus"); // 指定输出目录}).packageConfig(builder -> {builder.parent("com.zgf.study") // 设置父包名.moduleName("mybatisplus") // 设置父包模块名.pathInfo(Collections.singletonMap(OutputFile.mapperXml,"D://mybatis_plus"));// 设置mapperXml生成路径}).strategyConfig(builder -> {builder.addInclude("t_user","t_product","payment") // 设置需要生成的表名.addTablePrefix("t_", "c_"); // 设置过滤表前缀}).templateEngine(new FreemarkerTemplateEngine())// 使用Freemarker引擎模板,默认的是Velocity引擎模板.execute();}
}

最后会生成一套代码如下所示:

mybatisPlus笔记相关推荐

  1. MyBatis-Plus笔记

    学尚硅谷版mybatis-plus做的笔记 MyBatis-Plus简介 MyBatis-Plus(简称 MP)是一个 MyBatis的增强工具,在 MyBatis 的基础上只做增强不做改变,为 简化 ...

  2. Mybatis-plus笔记整理

    导入依赖 <!--MP--> <dependency><groupId>com.baomidou</groupId><artifactId> ...

  3. MyBatis-Plus 笔记

    目录 一.MyBatis-Plus 1.简介 2.使用 SpringBoot 快速使用 MyBatis-Plus 二.Mybatis-Plus 常用操作 1.配置日志 2.简单认识一下常用注解 3.代 ...

  4. mybatis-plus笔记(2)

    Lambda条件构造器 @Testpublic void selectByWrapperLambda() {// LambdaQueryWrapper<User> queryWrapper ...

  5. 【狂神】MyBatisPlus笔记

    目录 1. 特性 2. 快速入门 3. CRUD 3.1 insert 3.2 update 3.3 自动填充 3.4 乐观锁&悲观锁 3.5 查询操作 3.6 分页查询 3.7 delete ...

  6. MyBatis-plus自动填充功能之自动填充时间

    MyBatis-plus自动填充功能之自动填充时间 一.前期工作 二.自动填充 2.1 数据库级别 2.2 代码级别 在实际操作过程中,我们并不希望创建时间.修改时间这些来手动进行,而是希望通过自动化 ...

  7. MyBatis和MyBatis-plus教程

    MyBatis详解 Mybatis框架入门教程 MyBatisPlus笔记 狂神说MyBatis01:第一个程序 mybatis看这一篇就够了,简单全面一发入魂 三天撸完了MyBatis,各位随便问! ...

  8. 黑马SpringBoot --基础篇

    目录 导读 1.快速上手 1.1SpringBoot入门程序开发 1.1.1基础创建方式--常规 1.1.2手动创建方式--补充 1.1.3基础创建方式--下载 1.1.4基础创建方式--阿里云 1. ...

  9. SpringBoot2基础篇

    目录 前言 从今天开始进入微服务阶段 一. HelloWorld 1.1.什么是SpringBoot 1.3.微服务架构 二.第一个SpringBoot程序 2.1.环境配置 2.2.创建基础项目说明 ...

  10. 图片自适应等比缩放之object-fit

    object-fit:指定可替换元素的内容应该如何适应到其使用的高度和宽度确定的框.与我们熟悉的background-size属性有点相似. contain被替换的内容将被缩放,以在填充元素的内容框时 ...

最新文章

  1. 利用人类神经网络进行蛋白质设计
  2. 关于Visual Studio 2010与64位系统的问题
  3. 使用Iterator迭代器循环集合
  4. 损失函数为什么用平方形式(二)
  5. NVelocity的宏使用
  6. Java需要掌握的底层知识_java程序员需要知道的底层知识(一)
  7. 将读写锁放到共享内存中,实现进程之间对数据的读写访问控制
  8. ansible: Linux批量管理神器
  9. surfaceflinger类图
  10. AdGuard for Mac(专业的广告拦截工具)
  11. 【项目篇-项目创新点怎么写?(两千字图文总结建议)】创新创业竞赛项目计划书、新苗国创(大创)申报书
  12. Hello CSDN
  13. RELU激活函数作用
  14. 运用flask框架发送短信验证码的流程及具体代码
  15. linux中wps默认安装目录,在Linux系统中安装使用WPS的方法
  16. IntelliJ IDEA详细安装步骤
  17. 汽车/车载/自动驾驶/辅助驾驶相关认知记录
  18. 【裸金属服务器】安装VMware ESXi
  19. 一文读懂JS继承相关知识点
  20. 淘宝天猫店铺优惠券领取入口在哪里找到怎么领天猫淘宝店铺优惠券享受券后价优惠?

热门文章

  1. 【论文浅读】《Deep Pyramidal Residual Networks for Spectral–Spatial Hyperspectral Image Classification》
  2. [CSS3] 使用边框和背景(设置元素的背景)
  3. 史上最详细最易懂的EventBus源码解析
  4. 3.4.3 区域与图像的平均灰度值
  5. 最新电脑cpu性能排行服务器,服务器cpu性能如何 服务器cpu性能排行榜介绍【详解】...
  6. 电脑出现蓝屏运行慢怎么办
  7. 第39级台阶回溯算法c语言,回溯39级台阶
  8. Qt 使用-自定义菜单栏
  9. linux安装硬盘阵列卡驱动,centos7 RAID磁盘阵列卡驱动安装图文教程
  10. 自然语言处理(NLP)知识结构总结