How do I force a spring container not to return a singleton instance of a bean?

后端 未结 2 1973
刺人心
刺人心 2021-01-01 15:59

When I call getBean(name) on a BeanFactory, I get back an instance of the bean defined in the application context. However, when I call getB

2条回答
  •  天涯浪人
    2021-01-01 16:50

    You need to tell spring that you want a prototype bean rather than a singleton bean

    
    

    This will get you a new instance with each request.

提交回复
热议问题