bootstrap和application
时间: 2023-09-03 19:06:30 浏览: 78
bootstrap和application是Spring Boot中的两种上下文。bootstrap是应用程序的父上下文,用于加载额外的资源和配置信息。它主要用于从外部资源加载配置信息,还可以在本地外部配置文件中解密属性。bootstrap的属性会优先加载,并且默认情况下不能被本地相同配置覆盖。而application是应用程序的子上下文,用于加载应用程序的主要配置信息。它可以覆盖bootstrap中的属性。\[1\]
在使用Spring Boot时,如果在bootstrap中配置了某个属性,而在application中也配置了相同的属性,实际上应用程序启动时会使用application中的配置信息,而不是bootstrap中的配置信息。这是因为bootstrap不关心这个属性,它只负责加载额外的资源和配置信息。\[2\]
bootstrap的主要使用场景是从额外的资源加载配置信息,比如使用Spring Cloud Config配置中心时,可以在bootstrap配置文件中添加连接到配置中心的配置属性,以加载外部配置中心的配置信息。\[3\]
#### 引用[.reference_title]
- *1* *2* [bootstrap与application区别和应用场景](https://blog.csdn.net/xhf852963/article/details/102564107)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [springboot中的两种配置文件:application与bootstrap](https://blog.csdn.net/qq_43362086/article/details/129409296)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insert_down1,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)