【spring boot】設定檔 application.properties 屬性解析

來源:互聯網
上載者:User

標籤:插入   nbsp   png   資料丟失   常用   cat   span   處理   str   

1.JPA命名策略

spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.DefaultNamingStrategy

有兩種值可以配置分別為:

第一:org.hibernate.cfg.DefaultNamingStrategy 
第二:org.hibernate.cfg.ImprovedNamingStrategy  
DefaultNamingStrategy這個直接映射,不會做過多的處理(前提沒有設定@Table,@Column等屬性的時候)。如果有@Column則以@Column為準  ImprovedNamingStrategy 表名,欄位為小寫,當有大寫字母的時候會轉換為分隔字元號“_”。  

參考地址:http://blog.csdn.net/linxingliang/article/details/52566896

 

2.hibernate的DDL執行策略

spring.jpa.hibernate.ddl-auto=update

有下面5種值可以配置

①create

如果設定為該值,則每次載入hibernate時(準確說應是建立SessionFactory時)都會刪除以前建立的表而根據model重建表,即使前後的表沒有任何變化,通常會造成資料庫資料丟失,需謹慎使用這個取值

②create-drop

與create差不多,所不同的是每次sessionFactory關閉時,就會刪除所有表

③update

這個取值比較常用,需要先建立資料庫,在第一次載入hibernate時會自動建立表,以後建立hibernate會自動根據model更新表結構,即使表結構改變了,以前的行不會被刪除

④validate

每次載入hibernate時,驗證建立資料庫表結構,只會和資料庫中的表進行比較,不會建立新表,但是會插入新值

 

3.初始化資料庫時發生錯誤,不要停止

spring.datasource.continue-on-error=false 

預設值是false

 

4.

【spring boot】設定檔 application.properties 屬性解析

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.