微服務(wù) SpringBoot 2.0(六):常用配置(properties硝清、yml)

約定優(yōu)于配置,但配置不能為0 —— 知碼學(xué)院

引言

在前面的章節(jié)中转晰,我們已經(jīng)知道芦拿,SpringBoot的配置文件分為properties和yml砾肺,而我個(gè)人更青睞yml,其書(shū)寫格式讓人覺(jué)得很舒服防嗡,那這篇文章了就將配置文件中的各個(gè)屬性列出來(lái)供大家參考,在IDE工具中也會(huì)有相應(yīng)的提示侠坎,若出現(xiàn)紅色蚁趁,說(shuō)明該屬性已經(jīng)在2.0中變更,請(qǐng)查看變更后的書(shū)寫格式实胸。

SPRING CONFIG

spring.config.name
配置文件名稱他嫡,默認(rèn)為application
spring.config.location
配置文件存放位置,默認(rèn)為classpath目錄下

列出的類型如下:mvc庐完、messages钢属、mobile、view门躯、resource淆党、multipart、freemarker讶凉、thymeleaf染乌、mustcache、groovy模板懂讯、http荷憋、json、jersey

mvc


spring.mvc.date-format: yyyy-MM-dd
#設(shè)定日期的格式褐望,比如dd/MM/yyyy.

spring.mvc.favicon.enabled: true
#是否支持favicon.ico勒庄,默認(rèn)為: true

spring.mvc.ignore-default-model-on-redirect: true
#在重定向時(shí)是否忽略默認(rèn)model的內(nèi)容绞绒,默認(rèn)為true

spring.mvc.locale: abc
#指定使用的Locale.

spring.mvc.message-codes-resolver-format: PREFIX_ERROR_CODE
#指定message codes的格式化策略(PREFIX_ERROR_CODE,POSTFIX_ERROR_CODE).

spring.mvc.view.prefix: static
#指定mvc視圖的前綴.

spring.mvc.view.suffix: .html
#指定mvc視圖的后綴.

messages

spring.messages.basename
#指定message的basename涨颜,多個(gè)以逗號(hào)分隔,如果不加包名的話羞迷,默認(rèn)從classpath路徑開(kāi)始减宣,默認(rèn): messages

spring.messages.cache-seconds
#設(shè)定加載的資源文件緩存失效時(shí)間盐须,-1的話為永不過(guò)期,默認(rèn)為-1

spring.messages.encoding
#設(shè)定Message bundles的編碼漆腌,默認(rèn): UTF-8

mobile

spring.mobile.devicedelegatingviewresolver.enable-fallback
#是否支持fallback的解決方案贼邓,默認(rèn)false

spring.mobile.devicedelegatingviewresolver.enabled
#是否開(kāi)始device view resolver,默認(rèn)為: false

spring.mobile.devicedelegatingviewresolver.mobile-prefix
#設(shè)定mobile端視圖的前綴闷尿,默認(rèn)為:mobile/

spring.mobile.devicedelegatingviewresolver.mobile-suffix
#設(shè)定mobile視圖的后綴

spring.mobile.devicedelegatingviewresolver.normal-prefix
#設(shè)定普通設(shè)備的視圖前綴

spring.mobile.devicedelegatingviewresolver.normal-suffix
#設(shè)定普通設(shè)備視圖的后綴

spring.mobile.devicedelegatingviewresolver.tablet-prefix
#設(shè)定平板設(shè)備視圖前綴塑径,默認(rèn):tablet/

spring.mobile.devicedelegatingviewresolver.tablet-suffix
#設(shè)定平板設(shè)備視圖后綴.

spring.mobile.sitepreference.enabled
#是否啟用SitePreferenceHandler,默認(rèn)為: true

view

spring.view.prefix
#設(shè)定mvc視圖的前綴.

spring.view.suffix
#設(shè)定mvc視圖的后綴.

resource

spring.resources.add-mappings
#是否開(kāi)啟默認(rèn)的資源處理填具,默認(rèn)為true

spring.resources.cache-period
#設(shè)定資源的緩存時(shí)效统舀,以秒為單位.

spring.resources.chain.cache
#是否開(kāi)啟緩存匆骗,默認(rèn)為: true

spring.resources.chain.enabled
#是否開(kāi)啟資源 handling chain,默認(rèn)為false

spring.resources.chain.html-application-cache
#是否開(kāi)啟h5應(yīng)用的cache manifest重寫誉简,默認(rèn)為: false

spring.resources.chain.strategy.content.enabled
#是否開(kāi)啟內(nèi)容版本策略碉就,默認(rèn)為false

spring.resources.chain.strategy.content.paths
#指定要應(yīng)用的版本的路徑,多個(gè)以逗號(hào)分隔闷串,默認(rèn)為:[/**]

spring.resources.chain.strategy.fixed.enabled
#是否開(kāi)啟固定的版本策略瓮钥,默認(rèn)為false

spring.resources.chain.strategy.fixed.paths
#指定要應(yīng)用版本策略的路徑,多個(gè)以逗號(hào)分隔

spring.resources.chain.strategy.fixed.version
#指定版本策略使用的版本號(hào)

spring.resources.static-locations
#指定靜態(tài)資源路徑烹吵,默認(rèn)為classpath:[/META-INF/resources/,/resources/, /static/, /public/]以及context:/

multipart

multipart.enabled
#是否開(kāi)啟文件上傳支持碉熄,默認(rèn)為true

multipart.file-size-threshold
#設(shè)定文件寫入磁盤的閾值,單位為MB或KB肋拔,默認(rèn)為0

multipart.location
#指定文件上傳路徑.

multipart.max-file-size
#指定文件大小最大值锈津,默認(rèn)1MB

multipart.max-request-size
#指定每次請(qǐng)求的最大值,默認(rèn)為10MB

freemarker

spring.freemarker.allow-request-override
#指定HttpServletRequest的屬性是否可以覆蓋controller的model的同名項(xiàng)

spring.freemarker.allow-session-override
#指定HttpSession的屬性是否可以覆蓋controller的model的同名項(xiàng)

spring.freemarker.cache
#是否開(kāi)啟template caching.

spring.freemarker.charset
#設(shè)定Template的編碼.

spring.freemarker.check-template-location
#是否檢查templates路徑是否存在.

spring.freemarker.content-type
#設(shè)定Content-Type.

spring.freemarker.enabled
#是否允許mvc使用freemarker.

spring.freemarker.expose-request-attributes
#設(shè)定所有request的屬性在merge到模板的時(shí)候凉蜂,是否要都添加到model中.

spring.freemarker.expose-session-attributes
#設(shè)定所有HttpSession的屬性在merge到模板的時(shí)候琼梆,是否要都添加到model中.

spring.freemarker.expose-spring-macro-helpers
#設(shè)定是否以springMacroRequestContext的形式暴露RequestContext給Spring’s macro library使用

spring.freemarker.prefer-file-system-access
#是否優(yōu)先從文件系統(tǒng)加載template,以支持熱加載跃惫,默認(rèn)為true

spring.freemarker.prefix
#設(shè)定freemarker模板的前綴.

spring.freemarker.request-context-attribute
#指定RequestContext屬性的名.

spring.freemarker.settings
#設(shè)定FreeMarker keys.

spring.freemarker.suffix
#設(shè)定模板的后綴.

spring.freemarker.template-loader-path
#設(shè)定模板的加載路徑叮叹,多個(gè)以逗號(hào)分隔,默認(rèn): ["classpath:/templates/"]

spring.freemarker.view-names
#指定使用模板的視圖列表.

thymeleaf

spring.thymeleaf.cache
#是否開(kāi)啟模板緩存爆存,默認(rèn)true

spring.thymeleaf.check-template-location
#是否檢查模板路徑是否存在蛉顽,默認(rèn)true

spring.thymeleaf.enabled
#是否允許MVC使用Thymeleaf,默認(rèn)為: true

spring.thymeleaf.encoding
#指定模板的編碼先较,默認(rèn)為: UTF-8

spring.thymeleaf.excluded-view-names
#指定不使用模板的視圖名稱携冤,多個(gè)以逗號(hào)分隔.

spring.thymeleaf.mode
#指定模板的模式,具體查看StandardTemplateModeHandlers闲勺,默認(rèn)為: HTML5

spring.thymeleaf.prefix
#指定模板的前綴曾棕,默認(rèn)為:classpath:/templates/

spring.thymeleaf.suffix
#指定模板的后綴,默認(rèn)為:.html

spring.thymeleaf.template-resolver-order
#指定模板的解析順序菜循,默認(rèn)為第一個(gè).

spring.thymeleaf.view-names
#指定使用模板的視圖名翘地,多個(gè)以逗號(hào)分隔.

mustcache

spring.mustache.cache
#是否Enable template caching.

spring.mustache.charset
#指定Template的編碼.

spring.mustache.check-template-location
#是否檢查默認(rèn)的路徑是否存在.

spring.mustache.enabled
#是否開(kāi)啟mustcache的模板支持.

spring.mustache.prefix
#指定模板的前綴,默認(rèn): classpath:/templates/

spring.mustache.suffix
#指定模板的后綴癌幕,默認(rèn): .html

spring.mustache.view-names
#指定要使用模板的視圖名.

groovy模板

spring.groovy.template.allow-request-override
#指定HttpServletRequest的屬性是否可以覆蓋controller的model的同名項(xiàng)

spring.groovy.template.allow-session-override
#指定HttpSession的屬性是否可以覆蓋controller的model的同名項(xiàng)

spring.groovy.template.cache
#是否開(kāi)啟模板緩存.

spring.groovy.template.charset
#指定Template編碼.

spring.groovy.template.check-template-location
#是否檢查模板的路徑是否存在.

spring.groovy.template.configuration.auto-escape
#是否在渲染模板時(shí)自動(dòng)排查model的變量衙耕,默認(rèn)為: false

spring.groovy.template.configuration.auto-indent
#是否在渲染模板時(shí)自動(dòng)縮進(jìn),默認(rèn)為false

spring.groovy.template.configuration.auto-indent-string
#如果自動(dòng)縮進(jìn)啟用的話勺远,是使用SPACES還是TAB橙喘,默認(rèn)為: SPACES

spring.groovy.template.configuration.auto-new-line
#渲染模板時(shí)是否要輸出換行,默認(rèn)為false

spring.groovy.template.configuration.base-template-class
#指定template base class.

spring.groovy.template.configuration.cache-templates
#是否要緩存模板胶逢,默認(rèn)為true

spring.groovy.template.configuration.declaration-encoding
#在寫入declaration header時(shí)使用的編碼

spring.groovy.template.configuration.locale
#指定template locale.

spring.groovy.template.configuration.new-line-string
#當(dāng)啟用自動(dòng)換行時(shí)厅瞎,換行的輸出饰潜,默認(rèn)為系統(tǒng)的line.separator屬性的值

spring.groovy.template.configuration.resource-loader-path
#指定groovy的模板路徑,默認(rèn)為classpath:/templates/

spring.groovy.template.configuration.use-double-quotes
#指定屬性要使用雙引號(hào)還是單引號(hào)和簸,默認(rèn)為false

spring.groovy.template.content-type
#指定Content-Type.

spring.groovy.template.enabled
#是否開(kāi)啟groovy模板的支持.

spring.groovy.template.expose-request-attributes
#設(shè)定所有request的屬性在merge到模板的時(shí)候彭雾,是否要都添加到model中.

spring.groovy.template.expose-session-attributes
#設(shè)定所有session的屬性在merge到模板的時(shí)候,是否要都添加到model中.

spring.groovy.template.expose-spring-macro-helpers
#設(shè)定是否以springMacroRequestContext的形式暴露RequestContext給Spring’s macro library使用

spring.groovy.template.prefix
#指定模板的前綴.

spring.groovy.template.request-context-attribute
#指定RequestContext屬性的名.

spring.groovy.template.resource-loader-path
#指定模板的路徑锁保,默認(rèn)為: classpath:/templates/

spring.groovy.template.suffix
#指定模板的后綴

spring.groovy.template.view-names
#指定要使用模板的視圖名稱.

http

spring.hateoas.apply-to-primary-object-mapper
#設(shè)定是否對(duì)object mapper也支持HATEOAS冠跷,默認(rèn)為: true

spring.http.converters.preferred-json-mapper
#是否優(yōu)先使用JSON mapper來(lái)轉(zhuǎn)換.

spring.http.encoding.charset
#指定http請(qǐng)求和相應(yīng)的Charset,默認(rèn): UTF-8

spring.http.encoding.enabled
#是否開(kāi)啟http的編碼支持身诺,默認(rèn)為true

spring.http.encoding.force
#是否強(qiáng)制對(duì)http請(qǐng)求和響應(yīng)進(jìn)行編碼,默認(rèn)為true

json

spring.jackson.date-format
#指定日期格式抄囚,比如yyyy-MM-dd HH:mm:ss霉赡,或者具體的格式化類的全限定名

spring.jackson.deserialization
#是否開(kāi)啟Jackson的反序列化

spring.jackson.generator
#是否開(kāi)啟json的generators.

spring.jackson.joda-date-time-format
#指定Joda date/time的格式,比如yyyy-MM-dd HH:mm:ss). 如果沒(méi)有配置的話幔托,dateformat會(huì)作為backup

spring.jackson.locale
#指定json使用的Locale.

spring.jackson.mapper
#是否開(kāi)啟Jackson通用的特性.

spring.jackson.parser
#是否開(kāi)啟jackson的parser特性.

spring.jackson.property-naming-strategy
#指定PropertyNamingStrategy (CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES)或者指定PropertyNamingStrategy子類的全限定類名.

spring.jackson.serialization
#是否開(kāi)啟jackson的序列化.

spring.jackson.serialization-inclusion
#指定序列化時(shí)屬性的inclusion方式穴亏,具體查看JsonInclude.Include枚舉.

spring.jackson.time-zone
#指定日期格式化時(shí)區(qū),比如America/Los_Angeles或者GMT+10.

jersey

spring.jersey.filter.order
#指定Jersey filter的order重挑,默認(rèn)為: 0

spring.jersey.init
#指定傳遞給Jersey的初始化參數(shù).

spring.jersey.type
#指定Jersey的集成類型嗓化,可以是servlet或者filter.

作者有話說(shuō):喜歡的話就請(qǐng)移步知碼學(xué)院,請(qǐng)自備水谬哀,更多干刺覆、干、干貨等著你

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末史煎,一起剝皮案震驚了整個(gè)濱河市谦屑,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌篇梭,老刑警劉巖氢橙,帶你破解...
    沈念sama閱讀 221,820評(píng)論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異恬偷,居然都是意外死亡悍手,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,648評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門袍患,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)坦康,“玉大人,你說(shuō)我怎么就攤上這事协怒±员海” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 168,324評(píng)論 0 360
  • 文/不壞的土叔 我叫張陵孕暇,是天一觀的道長(zhǎng)仑撞。 經(jīng)常有香客問(wèn)我赤兴,道長(zhǎng),這世上最難降的妖魔是什么隧哮? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 59,714評(píng)論 1 297
  • 正文 為了忘掉前任桶良,我火速辦了婚禮,結(jié)果婚禮上沮翔,老公的妹妹穿的比我還像新娘陨帆。我一直安慰自己,他們只是感情好采蚀,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,724評(píng)論 6 397
  • 文/花漫 我一把揭開(kāi)白布疲牵。 她就那樣靜靜地躺著,像睡著了一般榆鼠。 火紅的嫁衣襯著肌膚如雪纲爸。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書(shū)人閱讀 52,328評(píng)論 1 310
  • 那天妆够,我揣著相機(jī)與錄音识啦,去河邊找鬼。 笑死神妹,一個(gè)胖子當(dāng)著我的面吹牛颓哮,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播鸵荠,決...
    沈念sama閱讀 40,897評(píng)論 3 421
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼冕茅,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了蛹找?” 一聲冷哼從身側(cè)響起嵌赠,我...
    開(kāi)封第一講書(shū)人閱讀 39,804評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎熄赡,沒(méi)想到半個(gè)月后姜挺,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 46,345評(píng)論 1 318
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡彼硫,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,431評(píng)論 3 340
  • 正文 我和宋清朗相戀三年炊豪,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片拧篮。...
    茶點(diǎn)故事閱讀 40,561評(píng)論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡词渤,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出串绩,到底是詐尸還是另有隱情缺虐,我是刑警寧澤,帶...
    沈念sama閱讀 36,238評(píng)論 5 350
  • 正文 年R本政府宣布礁凡,位于F島的核電站高氮,受9級(jí)特大地震影響慧妄,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜剪芍,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,928評(píng)論 3 334
  • 文/蒙蒙 一塞淹、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧罪裹,春花似錦饱普、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 32,417評(píng)論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至峡继,卻和暖如春箍铲,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背鬓椭。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 33,528評(píng)論 1 272
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留关划,地道東北人小染。 一個(gè)月前我還...
    沈念sama閱讀 48,983評(píng)論 3 376
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像贮折,于是被迫代替她去往敵國(guó)和親裤翩。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,573評(píng)論 2 359

推薦閱讀更多精彩內(nèi)容