Govt. Exams
Entrance Exams
Method parameters in @Bean methods allow Spring to inject dependent beans and establish bean relationships, enabling dependency injection at bean creation time.
@EnableAutoConfiguration (or @SpringBootApplication which includes it) auto-configures Spring beans based on jar dependencies on the classpath.
@Qualifier resolves ambiguity in autowiring by specifying the exact bean name or custom qualifier to inject when multiple beans of the same type exist.
@PropertySource loads properties from files, @ConfigurationProperties binds properties to bean properties, and @Value injects individual values. All are used for configuration.
@Lazy defers bean instantiation until it's first requested, overriding the default eager initialization behavior of singleton beans.
BeanFactory is the basic container, ObjectFactory is for lazy bean retrieval, and FactoryBean allows custom bean creation logic. All represent factory patterns in Spring.
PropertyPlaceholderConfigurer (or @PropertySource in modern Spring) enables externalization of configuration by replacing ${property.name} placeholders with actual values from properties files.
Spring provides multiple mechanisms for initialization: @PostConstruct, InitializingBean interface, and initMethod in @Bean definition. All are equally valid.
@Component is applied to classes making them beans automatically. @Bean is applied to methods in @Configuration classes, giving explicit control over bean creation.
When multiple beans match the injection point, Spring throws an exception unless @Primary is used to indicate the preferred bean or @Qualifier specifies which bean to inject.