Question: What is difference between singleton and prototype bean?Answer: Basically a bean has scopes which defines their existence on the applicationSingleton: means single bean definition to a single object instance per Spring IOC container. Prototype: means a single bean definition to any number of object instances. Whatever beans we defined in spring framework are singleton beans. There is an attribute in bean tag named singleton if specified true then bean becomes singleton and if set to false then the bean becomes a prototype bean. By default it is set to true. So, all the beans in spring framework are by default singleton beans. <bean id="createNewStock" class="springexample.stockMarket.CreateNewStockAccont" singleton="false"> <property name="newBid"/> </bean> |
Zum Wiederholen speichern
Speichere diesen Eintrag als Lesezeichen, markiere ihn als schwierig oder lege ihn in einem Wiederholungsset ab.
Melde dich an, um Lesezeichen, schwierige Fragen und Wiederholungssets zu speichern.
Ist das hilfreich? Ja Nein
Am hilfreichsten laut Nutzern:
- What is Spring?
- What are the advantages of Spring framework?
- What are features of Spring?
- What are the types of Dependency Injection Spring supports?
- Please describe the basic modules of Spring Framework.