[英]Why you don't need to specify the version for some dependencies in Spring Boot project?
[英]Why do you need to specify @Configuration when you want to use @PropertySource in Spring Boot?
我知道當您想為 ApplicationContext 添加@Bean 時,您會使用@Configuration。 但是為什么要在 Spring Boot 中使用@PropertySource 時需要指定@Configuration 呢?
來自@PropertySource
的 API 文檔:
注釋提供了一種方便的聲明機制,用於將
PropertySource
添加到 Spring 的環境中。 與@Configuration
類一起使用。
因此,可以推斷,如果我們使用@PropertySource
將由 Spring 容器管理,Spring 將注冊一個org.springframework.core.env.PropertySource
bean。 並且需要@Configuation
來聲明 Spring bean。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.