You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* A prototype scope means that a new instance of the bean is created each time it is requested. Each consumer gets a unique instance.
5
+
## Characteristics:
6
+
7
+
## Multiple Instances: A new instance is created every time the bean is requested from the application context.
8
+
## Memory Usage: Can consume more memory and resources since multiple instances may be created, especially if the bean is requested frequently.
9
+
## No Shared State: Each instance is independent, so changes to one instance do not affect others. This is useful for beans that need to maintain state that is unique per request or user.
10
+
## Use Cases:
11
+
* Stateful Beans: Ideal for beans that need to maintain unique state for each consumer or interaction.
12
+
* Transient Beans: Useful when beans are short-lived and their state should not be shared.
13
+
## example
14
+
```
15
+
@Component
16
+
@Scope("prototype")
17
+
public class PrototypeBean {
18
+
// A new instance is created each time the bean is requested
0 commit comments