Spring Core
The IoC container: dependency injection, beans, configuration, profiles, AOP and events.
The Spring container is a dependency-injection engine. Learn the idea in plain Java first, then see what the container automates.
Articles
- Dependency InjectionWhat dependency injection is, why constructor injection is the default, how a composition root works in plain Java, and what the Spring container automates — with a runnable before-and-after example and interview questions.
- ApplicationContext & BeanFactoryHow the Spring IoC container works: BeanFactory vs ApplicationContext, bean definitions, the refresh() startup sequence, BeanFactoryPostProcessor and BeanPostProcessor extension points, dependency resolution (by type, @Qualifier, @Primary, collections, ObjectProvider), circular dependencies, context hierarchies, and AOT processing.
- Bean lifecycle & scopesWhat happens to a Spring bean from definition to destruction: instantiation, injection, Aware callbacks, BeanPostProcessors, @PostConstruct and InitializingBean, SmartLifecycle, @PreDestroy and graceful shutdown; plus singleton, prototype, request, session and application scopes, scoped proxies, and thread-safety rules.
- Configuration & scanningDefining beans in Spring: stereotype annotations and component scanning, @Configuration and @Bean methods, full vs lite mode and proxyBeanMethods, @Import, profiles and @Profile, programmatic registration with BeanRegistrar (Spring 7), and how to organise configuration in large applications.
- SpELWhat SpEL is and where Spring uses it: syntax (literals, properties, methods, operators, collection selection and projection, safe navigation, Elvis), bean references, @Value with ${} vs #{}, SpEL in security, caching and scheduling annotations, evaluating expressions programmatically, compilation, and security risks of user-supplied expressions.
- AOP & proxiesHow Spring AOP adds cross-cutting behaviour: aspects, join points, pointcuts and advice; the five advice types with examples; pointcut expressions; JDK vs CGLIB proxies; ordering aspects; the self-invocation trap; which Spring features are built on AOP; and when to use AspectJ weaving instead.
- Application eventsDecoupling with Spring's event mechanism: publishing events, @EventListener, ordering and conditions, synchronous vs @Async listeners, @TransactionalEventListener phases, built-in lifecycle events, error handling, Spring Modulith's event publication registry, and when to use a message broker instead.