Spring Boot uses mybatis 3 to print SQL configuration

Source: Internet
Author: User

XML file configuration under normal spring:

<?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 caching -          <settingname= "cacheenabled"value= "true" />          <!--when querying, close the associated object to load in time to improve performance -          <settingname= "lazyloadingenabled"value= "false" />          <!--sets 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 -          <settingname= "Aggressivelazyloading"value= "false" />          <!--SQL queries for locations that allow different result sets to be returned to achieve a common effect -          <settingname= "multipleresultsetsenabled"value= "true" />          <!--allow column labels to be used instead of listed -          <settingname= "Usecolumnlabel"value= "true" />          <!--allows 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 policy will be overwritten -          <settingname= "Usegeneratedkeys"value= "true" />          <!--give nested resultmap with field-property mapping support -          <settingname= "Automappingbehavior"value= "PARTIAL" />          <!--caching SQL for bulk update operations for improved performance -          <settingname= "Defaultexecutortype"value= "Reuse" />          <!--Timeout If database is still not responding for more than 25,000 seconds -          <settingname= "Defaultstatementtimeout"value= "25000" />          <!--print Query statements-<!--<setting name= "Logimpl" value= "stdout_logging"/> --      </Settings>  </Configuration>  

Remember to add the red one.

Spring Boot configuration:

From the Logback.xml file configuration, the main point is to locate the package path to print the log, configure the level of printing.

<?XML version= "1.0" encoding= "UTF-8"?>    <ConfigurationScan= "true"Scanperiod= "Seconds">      <Appendername= "stdout"class= "Ch.qos.logback.core.ConsoleAppender">          <Encoder>              <pattern>%d{yyyy-m-d HH:mm:ss}%t%p%m%n</pattern>          </Encoder>      </Appender>      <Appendername= "Springboot"class= "Ch.qos.logback.core.rolling.RollingFileAppender">          <!--<Encoding>UTF-8</Encoding> -          <Rollingpolicyclass= "Ch.qos.logback.core.rolling.TimeBasedRollingPolicy">              <Filenamepattern>Logs/logback/springboot_%d{yyyy-m-d}.log</Filenamepattern>              <maxhistory>10</maxhistory>          </Rollingpolicy>          <Encoder>              <pattern>%d{yyyy-m-d HH:mm:ss}%t%p%m%n</pattern>          </Encoder>      </Appender>      <Appendername= "Smile"class= "Ch.qos.logback.core.rolling.RollingFileAppender">          <Rollingpolicyclass= "Ch.qos.logback.core.rolling.TimeBasedRollingPolicy">              <Filenamepattern>Logs/logback/smile_%d{yyyy-m-d}.log</Filenamepattern>              <maxhistory>10</maxhistory>          </Rollingpolicy>          <Encoder>              <pattern>%d{yyyy-m-d HH:mm:ss}%t%p%m%n</pattern>          </Encoder>      </Appender>        <Loggername= "Org.springframework.boot" Level= "Debug"additivity= "false">          <Appender-refref= "Springboot" />      </Logger>      <!--name package must be able to scan to so class, including startup class -      <logger name= "Com.smile" level= "Debug" additivity= "false" > <appender-ref ref= "Smile"/> < /logger>    <Root Level= "Info">          <Appender-refref= "stdout" />      </Root>  </Configuration>    

Tip: If you want to print the log from the console of Eclipse, change the additivity= "false" to true, this is to repeat the option setting for the print log, false to print only the file.

Reference:

http://blog.csdn.net/fan510988896/article/details/67638067 (the above content is transferred from this article)

http://blog.csdn.net/fan510988896/article/details/54409790 (the above content is transferred from this article)

Spring Boot uses mybatis 3 to print SQL configuration

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.