Posts

Showing posts from January, 2020

Spring | Singleton Vs ProtoType

By default, Spring beans are singletons.  singleton This scopes the bean definition to a single instance per Spring IoC container (default). prototype This scopes a single bean definition to have any number of object instances. The singleton scope If a scope is set to singleton, the Spring IoC container creates exactly one instance of the object defined by that bean definition. This single instance is stored in a cache of such singleton beans, and all subsequent requests and references for that named bean return the cached object. Here is the example package com.blogs; public class HelloWorld {    private String message;    public void setMessage(String message){       this.message  = message;    }    public void getMessage(){       System.out.println("Your Message : " + message);    } } Following is the content of the MainApp.java file − package co...