Govt. Exams
Entrance Exams
@SpringBootApplication is a convenience annotation that combines three key annotations for configuration, component scanning, and auto-configuration.
Singleton scope (default) creates one bean instance per application context that is shared and reused across the entire application.
ClassPathXmlApplicationContext loads Spring bean definitions from an XML file located in the classpath, allowing traditional XML-based configuration.
@Component marks a class as a bean, while @Bean is used inside @Configuration classes to define beans through factory methods, providing more control.
@Qualifier specifies the bean name to inject when multiple candidates exist. @Primary can also be used to mark a preferred bean.
@Configuration marks a class as a source of bean definitions. It's equivalent to an XML <beans> element and works with @Bean methods.
ApplicationContext is the central Spring container that manages bean lifecycle, performs DI, and provides additional features like event publishing and message resolution.
@Autowired(required=false) allows optional dependency injection. If the bean doesn't exist, no error is thrown.
IoC is a principle where the Spring Container manages object creation and lifecycle, not the application code itself.
By default, Spring creates beans as singletons - one instance per application context, shared across the entire application.