Spring Boot常見配置及錯誤

來源:互聯網
上載者:User

標籤:整合   debug   model   .class   color   com   run   use   bat   

一、SpringBoot常見配置

(1)SpingBoot與MyBatis整合時跟蹤SQL語句

log4j:  logger:    java:      sql:        ResultSet: TRACE

(2)日誌跟蹤

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

(3)MyBatis整合: 

#mybatis配置mybatis:  #配置映射類所在包名  type-aliases-package: com.xx.it.model  (資料庫實體物件所在路徑,一般為@Data對象,非Mapper注釋項所在路徑)  #配置mapper.xml檔案所在路徑  mapper-location: classpath:com/xx/it/*.xml(非必須項,可以不配)#不需要再配置Spring任何檔案@SpringBootApplication public class Application {   SpringApplication.run(Application.class,args); }

  Mapper所在路徑不需要配置,系統會自動掃描與Application同級及以下的所有目錄,同時對應的Spring也不需要配置

二、常見錯誤

(1)SpringBoot與MyBatis整合

  A.ResultMap與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:組裝資料庫中結果與實體物件的映射關係(將資料庫中查詢出來的結果映射給實體類)

   column:表中欄位名;property:實體類的屬性名稱

  

  

  

 

Spring Boot常見配置及錯誤

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.