SpringBoot学习笔记14——MybatisPlus模糊查询、输出执行sql

1.MybatisPlus的模糊查询

MybatisPlus的模糊查询非常简单,只需要进行简单的配置即可。

配置如下:

#默认查询时进行模糊查询
mybatis-plus.global-config.db-config.column-like=true

2.在控制台输出执行的sql语句

输出sql有两种方式

方法一:

首先需要配置一个config的路径

mybatis-plus.config-location: classpath:mybatis-config.xml

然后再xml文件中进行如下配置:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>

    <!--输出执行sql-->
    <settings>
        <setting name="logImpl" value="STDOUT_LOGGING"/>
    </settings>
</configuration>

方法二:

在properties文件中添加如下配置。

#显示sql
logging.level.com.youyou=DEBUG

猜你喜欢

转载自blog.csdn.net/lp840312696/article/details/83747755
今日推荐