引導應用程序上下文
一個Spring Cloud應用程序通過創建一個“引導”上下文來進行操作,這個上下文是主應用程序的父上下文。開箱即用,負責從外部源加載配置屬性,還解密本地外部配置文件中的屬性。這兩個上下文共享一個Environment
,這是任何Spring應用程序的外部屬性的來源。Bootstrap屬性的優先級高,因此默認情況下不能被本地配置覆蓋。
引導上下文使用與主應用程序上下文不同的外部配置約定,因此使用bootstrap.yml
?application.yml
(或.properties
)代替引導和主上下文的外部配置。
原文:The bootstrap context uses a different convention for locating external configuration than the main application context, so instead of?application.yml
?(or?.properties
) you use?bootstrap.yml
, keeping the external configuration for bootstrap and main context nicely separate.