Installation and use of Mybatis log plugin for IDEA plugin

A preface analysis

The sql log we see in the idea console is usually like this. In actual development and debugging, we want to copy the completed sql and analyze the data in the database. However, if our sql has dynamic parameter passing, the sq input output from the console will use "?" instead of the input parameter, which cannot be used directly.

SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2ba96bf] was not registered for synchronization because synchronization is not active
JDBC Connection [com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl@2dbb8d15] will not be managed by Spring
==>  Preparing: SELECT id,YEAR,VERSION_NAME,START_DATE,IS_NEW,CREATE_BY,CREATE_TIME,UPDATE_BY,UPDATE_TIME,IS_DELETE,FLOW_FLAG FROM T_BASE_ROUND_PROGRAMME WHERE id=?
==> Parameters: 1455748666023282333(String)
<==    Columns: ID, YEAR, VERSION_NAME, START_DATE, IS_NEW, CREATE_BY, CREATE_TIME, UPDATE_BY, UPDATE_TIME, IS_DELETE, FLOW_FLAG
<==        Row: 1455748666023282333, 2023, 2023版本, 2022-10-19 16:17:15.0, 1, linge2, 2022-10-19 16:17:24.0, linge2, 2022-10-19 16:17:30.0, 0, 1
<==      Total: 1
Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2ba96bf]

Two Mybatis log plug-in introduction

The Mybatis log plug-in solves the above problem of incomplete sql and can display sql completely.

  • Restore the sql log of mybatis to the original entire executable file sq.
  • The plug-in generates sql statements to replace ? with real parameter values.
  • Select console payroll log, right click "Restore Sql" menu Restore Sql.
  • Mutual navigation between Java methods and Mapper xml.

benefit

  • Quickly locate sql errors, no longer need to waste time on Copy code

insert image description here

Three Mybatis log plugin installation

The Mybatis log plug-in starts to charge after the ideal2020 version, and we need to install the green plug-in.

Link: https://pan.baidu.com/s/12UcdUSmG0fJMUZIH5v9bvw?pwd=1234
Extraction code: 1234

After downloading, drag it directly to ideal, ideal will automatically install it for us, and then restart ideal.

insert image description here

Four use Mybatis log plug-in

For the first use, you need to open the Mybatis Log console

  1. Click on TooL—Mybatis Log Plugin

insert image description here

  1. The Mybatis Log console will appear in the lower right corner of ideal

If you want to see sql later, you can just click it directly.
insert image description here
Note: The complete sql output can be seen in the Mybatis Log console, provided that the ideal console is configured to print the sql log.
You need to configure it in the properties file

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

Start a happy journey
insert image description here

Guess you like

Origin blog.csdn.net/weixin_43811057/article/details/129037941