Tag

Bean Scope

0 views collected around this technical thread.

Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
May 23, 2024 · Backend Development

Spring Prototype Bean Injection: ServiceLocator vs ObjectFactoryCreating

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 ScopeObjectFactoryCreatingFactoryBeanPrototype
0 likes · 9 min read
Spring Prototype Bean Injection: ServiceLocator vs ObjectFactoryCreating
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Jan 5, 2024 · Backend Development

Mastering Spring Bean Scopes: When to Use Singleton, Prototype, Request, Session, and More

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.

BackendBean ScopeJava
0 likes · 10 min read
Mastering Spring Bean Scopes: When to Use Singleton, Prototype, Request, Session, and More
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Oct 16, 2023 · Backend Development

Master Spring Bean Injection: Prototype in Singleton, Lazy, Transactions & More

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
Master Spring Bean Injection: Prototype in Singleton, Lazy, Transactions & More
Spring Full-Stack Practical Cases
Spring Full-Stack Practical Cases
Sep 5, 2023 · Backend Development

Mastering Spring Bean Scopes: Custom Scope Creation and Prototype Injection

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
Mastering Spring Bean Scopes: Custom Scope Creation and Prototype Injection
Code Ape Tech Column
Code Ape Tech Column
Sep 16, 2022 · Backend Development

Ensuring Thread Safety for Spring Singleton Beans: Problems and Solutions

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
Ensuring Thread Safety for Spring Singleton Beans: Problems and Solutions
Java Architect Essentials
Java Architect Essentials
Nov 24, 2021 · Backend Development

Understanding Spring Bean Scopes: Singleton vs Prototype

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
Understanding Spring Bean Scopes: Singleton vs Prototype
IT Xianyu
IT Xianyu
Nov 18, 2020 · Backend Development

Understanding Spring Framework: Core Concepts, Advantages, and Bean Management

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.

AOPBackendBean Scope
0 likes · 7 min read
Understanding Spring Framework: Core Concepts, Advantages, and Bean Management
Top Architect
Top Architect
Aug 6, 2020 · Backend Development

Understanding Spring Controller Bean Scope: Singleton vs Prototype and Thread Safety

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
Understanding Spring Controller Bean Scope: Singleton vs Prototype and Thread Safety
Java Captain
Java Captain
Oct 19, 2019 · Backend Development

Resolving Circular Dependencies in Spring: Constructor vs Setter Injection and Bean Scopes

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
Resolving Circular Dependencies in Spring: Constructor vs Setter Injection and Bean Scopes