Spring Singleton VS Java Singleton
Last updated
Was this helpful?
Last updated
Was this helpful?
Java singleton class is per classloader and Spring's singleton is per application context.
It is important to remember that your singleton beans should not store any state information. Because the bean instance created once will be shared across all the threads that are requesting for that spring bean. If you inject an object to spring’s singleton bean, it is wired only once and it never get refreshed. It is ideal to make all the controllers as the singleton beans and value objects as the prototype beans.