๐๐ SPRING CERTIFICATION QUESTION: Can you use @Bean together with @Profile?
๐๐ SPRING CERTIFICATION QUESTION: Can you use @Bean together with @Profile?
Answer:
๐ท๐๐๐๐๐๐ is itself meta-annotated with ๐ป๐๐๐๐๐ annotation which means that
it can be applied to methods, and more specifically factory ๐ฉ๐๐๐ methods.
Use cases for applying ๐ท๐๐๐๐๐๐ annotation on the method level:
1. Bean will only be registered in case the application runs with the same active profile declared in ๐ท๐๐๐๐๐๐ annotation.
2. In case of overloaded ๐ฉ๐๐๐ methods chosen ๐ท๐๐๐๐๐๐ must be the same for all overloaded methods.
If the profile is inconsistent among all overloaded methods, only ๐ท๐๐๐๐๐๐ of the first declared method will be considered.
Examples of mentioned terms:
๐ด๐๐๐๐๐ ๐ณ๐๐๐๐๐ท๐๐๐๐๐๐๐ช๐๐๐๐๐๐๐๐๐๐๐๐ - demonstrates simplistic usage of ๐ท๐๐๐๐๐๐ annotation applied at method level.
#spring #certificationquestion #vcp