An open API service indexing awesome lists of open source software.

https://github.com/kh77/springboot-prototypeinjection

3 ways to call prototype class within Singleton class
https://github.com/kh77/springboot-prototypeinjection

java spring-boot spring-injection

Last synced: about 2 months ago
JSON representation

3 ways to call prototype class within Singleton class

Awesome Lists containing this project

README

          

# Spring Boot - Prototype injection

We have a scenario to get the prototype bean from singleton
class but when we get the prototype bean then it will be
treated as a singleton because it is injected in
another singleton class. To solve this problem

- ApplicationContext
- ObjectFactory
- LookUp (Best way) : @Lookup tells Spring to return an
instance of the method's return type when we invoke it.