I know you use @Configuration when you want to add @Bean for ApplicationContext. But why do you need to specify @Configuration when you want to use @PropertySource in Spring Boot?
From the API documentaion of @PropertySource
:
Annotation providing a convenient and declarative mechanism for adding a
PropertySource
to Spring's Environment. To be used in conjunction with@Configuration
classes.
So, it can be deduced that Spring will register a org.springframework.core.env.PropertySource
bean if we use @PropertySource
which will be managed by the Spring container. And @Configuation
is needed for declaring Spring beans.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.