Entrance Exams
Govt. Exams
Spring doesn't enforce thread-safety for singleton beans. Developers must implement thread-safe code, use immutable objects, or utilize synchronization where necessary.
Stereotype annotations (@Service, @Repository, @Controller) enable classpath component scanning and convey the architectural role of the class.
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.
Prototype scope creates a new bean instance each time it's requested, unlike singleton which creates only one instance for the entire application.
@Profile is for environment-based activation, @Conditional for custom logic, and @ConditionalOnProperty for property-driven bean registration. Choice depends on specific requirements.
@Qualifier resolves ambiguity in autowiring by specifying the exact bean name or custom qualifier to inject when multiple beans of the same type exist.
ObjectFactory enables lazy initialization, provides new instances for prototype beans, and can help resolve circular dependencies through deferred access.
ApplicationContext extends BeanFactory and adds features like event publishing, message resource handling, and easier AOP integration.
@PropertySource loads properties from files, @ConfigurationProperties binds properties to bean properties, and @Value injects individual values. All are used for configuration.