Tagged articles
Bean Scope
22 articles · Page 1 of 1
This article walks through the ten most frequently asked Spring interview topics—including IoC/DI concepts, bean lifecycle, AOP mechanics, circular‑dependency resolution, @Transactional behavior, Spring Boot startup steps, auto‑configuration, @Autowired vs @Resource, bean scopes, and the differences between servlet filters and Spring interceptors—providing concrete code examples and key points that can earn interviewers' extra credit.
AOPBean ScopeIoC
0 likes · 12 min read

The article explains the five Spring Bean scopes, clarifies that scope only controls instance count and not thread safety, and walks through real‑world concurrency bugs such as mutable singleton fields, prototype beans losing their prototype nature, and request‑scoped beans failing in async threads, offering concrete fixes and usage recommendations.
Bean ScopeConcurrencyJava
0 likes · 10 min read


Java OneDec 12, 2025 · Backend Development
This article explains how Spring manages bean instances, compares singleton and prototype scopes with concrete code examples, and shows why two injected beans may be equal or different depending on the @Scope annotation applied to the component class.
Bean ScopeJavadependency-injection
0 likes · 3 min read

This concise guide explains Spring’s core concepts—including the Inversion of Control container, how beans are created and managed, the different bean scopes, and the full bean lifecycle with key extension points—providing clear analogies and practical configuration examples.
Bean LifecycleBean ScopeIoC
0 likes · 6 min read

An in‑depth guide to Spring Bean scopes explains the seven standard scopes—including Singleton, Prototype, Request, Session, Application, Global Session, and WebSocket—detailing their lifecycles, configuration methods, core principles, and best‑practice scenarios to help developers choose the optimal scope for high‑performance, reliable applications.
Bean ScopeSpringWebSocket
0 likes · 12 min read

This article explains the operation of the Spring IoC container, the DIP principle, dependency injection, XML bean definitions, custom and static factories, FactoryBean usage, bean scopes (singleton and prototype), and demonstrates their behavior with Java code examples.
Bean ScopeFactoryBeanSpring
0 likes · 6 min read

This article explains how to define and inject prototype-scoped beans in Spring using @Scope, ServiceLocatorFactoryBean, and ObjectFactoryCreatingFactoryBean, demonstrates configuration via annotations and XML, shows code examples, compares the two FactoryBean approaches, and includes tips for bean name mapping and custom exceptions.
Bean ScopeObjectFactoryCreatingFactoryBeanServiceLocatorFactoryBean
0 likes · 9 min read

This article explains Spring's bean scopes—including singleton, prototype, request, session, and application—detailing their lifecycles, appropriate use cases, and how to configure them with code examples, while also covering common pitfalls and proxy solutions for web environments.
Bean ScopeJavaSpring
0 likes · 10 min read

This guide explains how to handle various Spring bean injection and transaction challenges, including injecting prototype beans into singletons, using @Lazy, registering abstract beans, resolving multiple bean conflicts, forcing rollback without exceptions, injecting static fields, ensuring transaction consistency, enabling non‑public transactional methods, custom component scanning, and adding interfaces via AOP.
Bean ScopeJavaSpring
0 likes · 12 min read

This article explains how Spring's @Scope annotation determines bean lifecycles, demonstrates creating and registering a custom scope, and shows how to correctly inject prototype-scoped beans into singleton components using scoped proxies.
Bean ScopeCustom ScopeJava
0 likes · 7 min read

This article explains why Spring singleton beans can be unsafe in concurrent scenarios, demonstrates the issue with a controller example, and presents multiple solutions including changing bean scope, using ThreadLocal, avoiding member variables, employing concurrent collections, and leveraging distributed caches.
BackendBean ScopeSpring
0 likes · 8 min read

This article explains the differences between Spring's singleton and prototype bean scopes, describing how singleton beans are cached and shared across requests while prototype beans are created anew each time, and discusses their performance advantages, thread‑safety drawbacks, and practical implications for developers.
BackendBean ScopeJava
0 likes · 5 min read

This article explains the differences between stateful and stateless Spring beans, the impact of singleton and prototype scopes on thread safety, and demonstrates how ThreadLocal can be used to safely share resources in multithreaded backend applications, complete with code examples.
Bean ScopeJavaSpring
0 likes · 13 min read

This article provides a comprehensive overview of the Spring framework, explaining its IoC and AOP core, architectural layers, key advantages such as decoupling and declarative transactions, bean scopes, lifecycle settings, and practical object‑creation methods for Java backend development.
BackendBean ScopeIoC
0 likes · 7 min read

This article explains that Spring Boot controllers are singleton by default, why that makes them unsafe when using non‑static fields, demonstrates the problem with sample code, and provides practical solutions such as using prototype scope or ThreadLocal variables.
Bean ScopeControllerprototype
0 likes · 5 min read

This article explains Spring's bean scopes, compares singleton and prototype beans regarding thread safety, demonstrates the issue with shared state through code examples, and provides practical solutions such as using prototype scope or ThreadLocal to avoid concurrency problems.
Bean ScopeJavaSpring
0 likes · 5 min read

Spring MVC controllers are singleton by default, which can cause thread‑unsafe behavior when using non‑static member variables; this article demonstrates the issue with example endpoints, shows how prototype scope resolves it, and outlines best practices such as avoiding stateful fields or using ThreadLocal.
Bean ScopeControllerJava
0 likes · 5 min read

This article explains why Spring MVC controllers are singleton by default, demonstrates the thread‑safety issues caused by shared instance variables, shows how to test the behavior with sample code, and presents solutions such as using prototype scope, avoiding member variables, or employing ThreadLocal.
Bean ScopeControllerJava
0 likes · 6 min read

This article explains what circular dependencies are in Spring, shows three ways the framework handles them—constructor injection, singleton setter injection, and prototype setter injection—illustrates each with Java classes and XML configuration, and clarifies why only the singleton setter approach avoids runtime errors.
Bean ScopeCircular DependencyConstructor Injection
0 likes · 9 min read

This article explains Spring's five bean scopes, focusing on the differences between singleton and prototype beans, their performance advantages, thread-safety concerns, and why Spring chooses singleton as the default scope.
Bean ScopeSpringperformance
0 likes · 5 min read

This article explains how Spring bean scopes affect thread safety, why most beans are safe when stateless, how to use ThreadLocal correctly, its internal hash‑map design, and the memory‑leak pitfalls that arise when ThreadLocal entries are not cleaned up.
Bean ScopeJavaMemory Leak
0 likes · 16 min read

This article explains how Spring handles circular dependencies through constructor injection errors, demonstrates how setter injection with singleton scope avoids the issue, and shows why prototype‑scoped beans still fail, providing code examples and internal mechanism details.
Bean ScopeCircular DependencyConstructor Injection
0 likes · 9 min read
