spring boot配置文件详解
生活随笔
收集整理的這篇文章主要介紹了
spring boot配置文件详解
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
spring boot配置文件詳解
application.properties是spring-boot的核心配置文件,這個配置文件基本可以取代我們ssm或者ssh里面的所有的xml配置文件。
當我們啟動springboot工程做的第一件事就是加載application.properties屬性配置文件。
application.properties雖然有時候是空的,也能正常啟動,是因為,application.properties有很多默認配置,這也說明了springboot是一個開箱即用的。也就是約定優于配置的實踐。
Springboot有很多默認配置參考springboot文檔
比如:編碼對中文支持很友好,統一utf-8
比如:tomcat端口號
server.port=8080 # Server HTTP port.
//pojo中有date類型怎么轉string類型就靠這兩個配置
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=Asia/Chongqing
參數間引用
com.niwotaxuexiba.author.name=zhangxueliang com.niwotaxuexiba.author.sex= male com.niwotaxuexiba.author.desc=${com.niwotaxuexiba.author.name} ${com.niwotaxuexiba.author.sex}隨機數
# 隨機字符串 com.value=${random.value} # 隨機int com.number=${random.int} # 隨機long com.bignumber=${random.long} # 10以內的隨機數 com.test1=${random.int(10)} # 10-20的隨機數 com.test2=${random.int[10,20]}總結
以上是生活随笔為你收集整理的spring boot配置文件详解的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: spring boot编写并运行Hell
- 下一篇: spring boot通过命令行配置属性