导读:为方便查看sql语句,因为一般sql在控制台打印是预处理的select… from table where ss=,有时查询条件太长复制参数赋值很麻烦,因此写下这篇文章作记录,拿取完整的sql。
配置比较简单,基本是引用jar包后,然后在配置上稍微改下,即可打印sql完整日志
p6spy
p6spy
3.8.1
mysql配置文件,加上jdbc:p6spy,及driver-class-name改成com.p6spy.engine.spy.P6SpyDriver
spring:
datasource:
host: jdbc:p6spy:mysql://xxxxxx:3306
url: ${spring.datasource.host}/xxxx?useUnicode=true&characterEncoding=utf8&tinyInt1isBit=false&autoReconnect=true&useSSL=false&serverTimezone=Asia/Shanghai
username: xxxxxx
password: xxxxxx
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
initialSize: 5
minIdle: 5
maxActive: 20
这种基本是改配置文件,然后安装插件,即可看到有打印
添加打印mybatis-plus的sql语句
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
然后按以下这篇文章操作
Mybatis Log 控制台输出打印SQL语句
结果
二选一,用p6spy注意生产不要打开