Announcement Announcement Module
No announcement yet.
Ho to make non singleton bean Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Ho to make non singleton bean

    Hi I am using spring in my project, i want to make my bean as non singleton. I made sigleton="false" in my xml configuration also.
    DTD version is ""
    Can any please help me out in this regard.
    Thanks in advance.

    Y Kumar Reddy

  • #2
    The attribute you're looking for is 'scope' on the 'bean' element:

    <bean class="" scope="prototype" />


    • #3
      Bean Scopes

      You may have a look at the spring documentation, which explains bean scopes.

      The prototype scope will create a new instance of the class whenever a call to applicationContext.getBean(name) is called.

      If you are injecting the prototype bean into another bean then during the creation of the referencing bean a new instance of the prototype bean will be created, That means referencing bean will always use a single instance of the prototype bean during its scope, it will not use different instances of the prototype bean.