配置檔案:
1.environment 讀取#服務埠號
server:
port: 8081
proper:
key: $
id: $
value: test123
demo:
val: autoinject
使用方式:
2.@value 註解方式@restcontroller
public class democontroller
}
@value註解可以將配置資訊注入到bean的屬性,也是比較常見的使用方式,但有幾點需要額外注意
如果配置資訊不存在會怎樣?
配置衝突了會怎樣(即多個配置檔案中有同乙個key時)?
使用方式如下,主要是通過 ${},大括號內為配置的key;
如果配置不存在時,給乙個預設值時,可以用冒號分割,後面為具體的值
3.物件對映方式@restcontroller
public class democontroller
}
擴充套件:@data
@component
public class properbean
properties配置優先順序 > yaml配置優先順序
springboot配置資訊
server.context path center 應用上下文,在所有的controller之前 server.servlet path html 拼接在controller後面,eg http localhost 8080 center index.html server.servlet.con...
Spring Boot 配置資訊
spring boot 配置資訊 1 feign 超時配置 2 上傳檔案大小控制 3 jackson的配置 4 value 註解 5 日誌配置 1 feign 超時配置 feign client config default connect timeout 600000 read timeout 6...
spring boot 配置檔案讀取
如圖所示,可以重新賦值予以覆蓋。mail setting 設定郵箱主機 email.host smtp.163.com email.port 25 設定使用者名稱 email.from xx xx.com 設定密碼 email.frompassword 設定是否需要認證,如果為true,那麼使用者名...