Configure Mybatis to print sql in SpringBoot

When using mybatis, the sql statement is only printed under debug, and we only configure info, so if you want to view the sql statement, there are two operations: The first is to change <root level="info"> to < root level="DEBUG">This will print sql, but there will be many other messages in the log. The second is to configure the debug mode for the dao directory separately, the code is as follows, so that the configured sql statement will be printed, and other normal info level:

If you are using the application.properties file, add the following configuration:

logging.level.com.example.demo.dao=debug

logging.level.com, the path behind refers to the package where the method interface corresponding to mybatis is located. Not the package where mapper.xml is located.

If you are using the application.yml file, add the following configuration:

# 打印sql
logging:
  level:
     com.example.demo.dao : debug
 

Guess you like

Origin blog.csdn.net/QRcode_Y/article/details/107832626