Announcement Announcement Module
Collapse
No announcement yet.
Ho to make non singleton bean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • 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 "http://www.springframework.org/dtd/spring-beans.dtd"
    Can any please help me out in this regard.
    Thanks in advance.

    Regards,
    Y Kumar Reddy

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

    Code:
    <bean class="baz.bar.Foo" scope="prototype" />

    Comment


    • #3
      Bean Scopes

      You may have a look at the spring documentation http://static.springframework.org/sp...factory-scopes, 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.

      Comment

      Working...
      X