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