Question : What is difference between singleton and prototype bean?Reponse : 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> |
Enregistrer pour revision
Ajoutez cet element aux favoris, marquez-le comme difficile ou placez-le dans un ensemble de revision.
Connectez-vous pour enregistrer des favoris, des questions difficiles et des ensembles de revision.
Est-ce utile ? Oui Non
Les plus utiles selon les utilisateurs :
- 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.