Relative Content

Tag Archive for javaspringsingletonprototype

How to Handle bean scope in Spring singleton class to avoid older data in list with new data

I need to update the Spring bean scope so that older data is not processed along with new data. Let’s say we have a list managed by an object called Obj1. We add an item to the list, such as “Hi”. Later, another object called Obj2 adds a new item to the same list, like “Hello”. When we print the method using Obj1, it should display “Hi”. However, when we call the print method using Obj2, it should only print its added value, which is “Hello”