Spring boot common Configuration and errors

Source: Internet
Author: User

First, Springboot common configuration

(1) Spingboot Tracking SQL statements when integrated with MyBatis

log4j:  Logger:    java:      sql:        resultset:trace

(2) Log tracking

Debug:  truelogging:   config:  classpath:log4j2/log4j2.xml

(3) MyBatis Integration:

#mybatis配置mybatis:  #配置映射类所在包名  type-aliases-package:com.xx.it.model  (the path to the database entity object, typically the @data object, The path of the non-mapper annotation entry) #配置mapper the path to the  . xml file  Mapper-location:classpath:com/xx/it/*.xml (not required) # No longer need to configure spring any file @springbootapplication public class Application {   Springapplication.run (Application.class, args); }

Mapper the path does not need to be configured, the system will automatically scan all directories with application peers and below , while the corresponding spring does not need to be configured

Ii. Common Mistakes

(1) Springboot and MyBatis Integration

Problems caused by A.resultmap and Resulttype

<resultmap id= "Sample" type= "Com.xx.it.SampleVo" >  <result property= "id" column= "id"/>  < Result property= "name" column= "name"/>  <result property= "Useyn" column= "Use_yn"/></resultmap> <select id= "Selectsample" resultmap= "Sample" >  select Id,name,useyn from sample where id = #{id}</select ><select id= "getreply" parametertype= "Samplevo" resulttype= "Sample" >  select Id,name,useyn from sample WHERE id = #{id}</select>

  

Resultmap: Mapping relationships between results in the Assembly database and entity objects (mapping results from a database to entity classes)

Column: The name of the field in the table; property: The attribute name of the entity class

  

Spring boot common Configuration and errors

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.