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> |
復習用に保存
この項目をブックマークに追加したり、難しい内容としてマークしたり、復習セットに入れたりできます。
役に立ちましたか? はい いいえ
ユーザー評価で最も役立つ内容:
- 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.