在application.properties中加上下面部分代码,可以查看被mp底层封装的sql。

#mybatis日志
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl

运行会打印

Creating a new SqlSession
SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@16d07cf3] was not registered for synchronization because synchronization is not active
JDBC Connection [HikariProxyConnection@1198531054 wrapping com.mysql.cj.jdbc.ConnectionImpl@2180e789] will not be managed by Spring
==>  Preparing: SELECT id,name,age,email FROM user 
==> Parameters: 
<==    Columns: id, name, age, email
<==        Row: 1, wz, 18, wz@qq.com
<==        Row: 2, wd, 28, wd@qq.com
<==      Total: 2
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@16d07cf3]