日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

spring boot配置文件详解

發布時間:2025/1/21 编程问答 11 豆豆
生活随笔 收集整理的這篇文章主要介紹了 spring boot配置文件详解 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

spring boot配置文件詳解

application.properties是spring-boot的核心配置文件,這個配置文件基本可以取代我們ssm或者ssh里面的所有的xml配置文件。


當我們啟動springboot工程做的第一件事就是加載application.properties屬性配置文件。


application.properties雖然有時候是空的,也能正常啟動,是因為,application.properties有很多默認配置,這也說明了springboot是一個開箱即用的。也就是約定優于配置的實踐。

Springboot有很多默認配置參考springboot文檔
比如:編碼對中文支持很友好,統一utf-8

spring.messages.encoding=UTF-8 # Message bundles encoding. server.tomcat.uri-encoding=UTF-8 # Character encoding to use to decode the URI. spring.freemarker.charset=UTF-8 # Template encoding. spring.http.encoding.charset=UTF-8 # Charset of HTTP requests and responses. Added to the "Content-Type"

比如: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配置文件详解的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。