When the foreground request data, the SQL statement has been printed to the console, there is an idea is to let it print to the log, how to do?
See the following mybatis configuration file:
[HTML]View PlainCopyPrint?
- <? 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 >
- <!--set Run parameters --
- < Settings >
- <!--Global Mapper Enable cache --
- < setting name="cacheenabled" value="true" />
- < when!--query, close the associated object and load it in time to improve performance--
- < setting name="lazyloadingenabled" value="false" />
- <!--Set the shape of the associated object load, where the field is loaded on demand (the Load field is specified by SQL) and all fields of the associated table are not loaded to improve performance --
- < setting name="aggressivelazyloading" value="false" />
- <!--SQL queries for locations, allowing different result sets to be returned to achieve a common effect--
- < setting name="multipleresultsetsenabled" value=" True " />
- <!--allow column labels to be used instead of columns --
- < setting name="Usecolumnlabel" value="true" />
- <!--allows you to use a custom primary key value (such as a program-generated UUID 32-bit encoding as the key value), and the PK generation strategy for the data table will be overwritten -
- < setting name="Usegeneratedkeys" value="true" />
- <!--given nested resultmap with field-property mapping support-
- < setting name="Automappingbehavior" value="PARTIAL" />
- <!--cache SQL for bulk update operations to improve performance --
- < setting name="Defaultexecutortype" value="Reuse" />
- <!--The database is still not responding for more than 25,000 seconds timeout -
- < setting name="defaultstatementtimeout" value="25000 " />
- <!--print query statements --
- <!--<setting name= "Logimpl" value= "stdout_logging"/> --
- </ Settings >
- </ Configuration >
<?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> <!--set Run parameters--<settings> <!--Global Mapper Enable Cache--<setting name = "Cacheenabled" value= "true"/> <!--query, close the associated object to load in time to improve performance--<setting name= "lazyloadingenabled" Value= "false"/> <!--sets the form of the associated object load, where the field is loaded on demand (the Load field is specified by SQL) and all fields of the associated table are not loaded to improve performance--<setting name= "AG Gressivelazyloading "value=" false "/> <!--SQL query for location, allowing different result sets to be returned to achieve a common effect--<setting name=" mult Ipleresultsetsenabled "value=" true "/> <!--allow column labels to be used instead of columns--<setting name= ' Usecolumnlabel ' value = "true"/> <!--allow the use of custom primary key values (such as the program-generated UUID 32-bit encoding as the key value), the data table PK generation strategy will be overwritten--<setting name= "Usegenera Tedkeys "value=" true "/> <!--gives nested resultmap with field-property mapping support--<setting name=" aUtomappingbehavior "value=" PARTIAL "/> <!--cache SQL for bulk update operations to improve performance--<setting name=" Defaultexecuto Rtype "value=" Reuse "/> <!--database is still not responding for more than 25,000 seconds timeout---<setting name=" Defaultstatementtimeout "Valu E= "25000"/> <!--print Query statements-<!--<setting name= "Logimpl" value= "stdout_logging"/>-- </settings></configuration>
[HTML]View PlainCopyPrint?
- < setting name="Logimpl" value="Stdout_ LOGGING " />
<setting name= "Logimpl" value= "stdout_logging"/>
That's the sentence!
If you annotate it, your SQL can print into the log
If you let it go, your SQL will print to the console
How to configure the log printing in the Springboot? You can refer to another article:
Use Logback to print logs in Springboot
Springboot consolidation mybatis Print SQL to log (GO)