Singleton Bean Scope in Spring

<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;" trbidi&equals;"on">&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;" trbidi&equals;"on">&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;" trbidi&equals;"on"><b>Singleton Bean Scope&colon; <&sol;b>Scopes a single bean definition to a single object instance per <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;06&sol;spring-ioc-container&period;html">Spring IoC container<&sol;a>&period; This is the default behavior of the <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;06&sol;spring-ioc-container&period;html">spring container<&sol;a>&period;&nbsp&semi; <&sol;p>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;">When a bean is a <b>singleton<&sol;b>&comma; only one <i>shared<&sol;i> instance of the bean will be managed&comma; and all requests for beans with an<i><b> id or ids<&sol;b><&sol;i> matching that bean definition will result in that one specific bean instance being returned by the <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;06&sol;spring-ioc-container&period;html">Spring container<&sol;a>&period;<&sol;p>&NewLine;<&sol;div>&NewLine;<div align&equals;"center" id&equals;"ads-id"><&sol;div>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;">We can say another way&comma; <b>when you define a bean definition and it is scoped as a singleton&comma;<&sol;b> then the <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;06&sol;spring-ioc-container&period;html">Spring IoC container<&sol;a> will create <b><i>exactly one<&sol;i> <i>instance <&sol;i><&sol;b>of the object defined by that bean definition&period; This single instance will be stored in a cache of such singleton beans&comma; and <b><i>all&nbsp&semi;<&sol;i><&sol;b><&sol;div>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;"><b><i><br &sol;>&NewLine;<&sol;i><&sol;b> <b><i>Lets see with example which show the singleton scope of the &&num;8216&semi;zeroPoint&&num;8217&semi; bean in the spring container&period;<&sol;i><&sol;b><&sol;div>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;"><&sol;div>&NewLine;<&sol;div>&NewLine;<div style&equals;"background-color&colon; &num;f2f9fc&semi; border&colon;1px solid &num;c9e6f2&semi;border-radius&colon;3px&semi;padding&colon;16px&semi;line-height&colon;1&period;45&semi;"><b>Popular Tutorials<&sol;b><&sol;p>&NewLine;<ul style&equals;"text-align&colon; left&semi;">&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;06&sol;spring-30-baby-step-to-learn&period;html"><em><strong>Spring Tutorial<&sol;strong> <&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;12&sol;spring-web-mvc-framework-chapter-38&period;html"><strong><em>Spring MVC Web Tutorial <&sol;em><&sol;strong><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2016&sol;06&sol;introduction-to-spring-boot-a-spring-boot-complete-guide&period;html"><em><strong>Spring Boot Tutorial<&sol;strong> <&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2013&sol;02&sol;spring-security-take-baby-step-to-secure&period;html"><em>Spring Security Tutorial<&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;03&sol;spring-aop-tutorial-with-example-aspect-advice-pointcut-joinpoint&period;html"><em>Spring AOP Tutorial<&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;12&sol;using-spring-jdbc-framework-chapter-32&period;html"><em>Spring JDBC Tutorial<&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;01&sol;spring-hateoas-hypermedia-driven-restful-web-service&period;html"><em><strong>Spring HATEOAS <&sol;strong><&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;01&sol;microservices-with-spring-boot&period;html"><em><strong>Microservices with Spring Boot<&sol;strong><&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2013&sol;06&sol;jax-rs-web-service-tutorial&period;html"><strong><em>REST Webservice<&sol;em> <&sol;strong><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2013&sol;01&sol;core-java-baby-step-to-be-best-java-ian&period;html"><em><strong>Core Java <&sol;strong><&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;03&sol;hibernate-3-on-baby-steps&period;html"><em><strong>Hibernate Tutorial<&sol;strong><&sol;em><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;12&sol;spring-batch-process-with-example&period;html"><strong><em>Spring Batch<&sol;em> <&sol;strong><&sol;a><&sol;b><&sol;li>&NewLine;<&sol;ul>&NewLine;<&sol;div>&NewLine;<p><b><br &sol;>&NewLine;<&sol;b> <b>Point&period;java<&sol;b><&sol;p>&NewLine;<pre class&equals;"highlight" name&equals;"code">package com&period;dineshonjava&period;sdnext&period;beanscope&period;tutorial&semi;&NewLine;&NewLine;public class Point&NewLine;&lbrace;&NewLine; private int x&semi;&NewLine; private int y&semi;&NewLine; &sol;&ast;&ast;&NewLine; &ast; &commat;return the x&NewLine; &ast;&sol;&NewLine; public int getX&lpar;&rpar; &lbrace;&NewLine; return x&semi;&NewLine; &rcub;&NewLine; &sol;&ast;&ast;&NewLine; &ast; &commat;param x the x to set&NewLine; &ast;&sol;&NewLine; public void setX&lpar;int x&rpar; &lbrace;&NewLine; this&period;x &equals; x&semi;&NewLine; &rcub;&NewLine; &sol;&ast;&ast;&NewLine; &ast; &commat;return the y&NewLine; &ast;&sol;&NewLine; public int getY&lpar;&rpar; &lbrace;&NewLine; return y&semi;&NewLine; &rcub;&NewLine; &sol;&ast;&ast;&NewLine; &ast; &commat;param y the y to set&NewLine; &ast;&sol;&NewLine; public void setY&lpar;int y&rpar; &lbrace;&NewLine; this&period;y &equals; y&semi;&NewLine; &rcub;&NewLine;&rcub;&NewLine;<&sol;pre>&NewLine;<p>&NewLine;<b><br &sol;>&NewLine;<&sol;b> <b>spring&period;xml<&sol;b><&sol;p>&NewLine;<pre class&equals;"highlight" name&equals;"code">&lt&semi;beans xmlns&colon;aop&equals;"http&colon;&sol;&sol;www&period;springframework&period;org&sol;schema&sol;aop" xmlns&colon;p&equals;"http&colon;&sol;&sol;www&period;springframework&period;org&sol;schema&sol;p" xmlns&colon;><b><br &sol;>&NewLine;<&sol;b> <b>DrawingApp&period;java<&sol;b><br &sol;>&NewLine;<pre class&equals;"highlight" name&equals;"code">package com&period;dineshonjava&period;sdnext&period;beanscope&period;tutorial&semi;&NewLine;&NewLine;import org&period;springframework&period;context&period;ApplicationContext&semi;&NewLine;import org&period;springframework&period;context&period;support&period;ClassPathXmlApplicationContext&semi;&NewLine;&NewLine;&sol;&ast;&ast;&NewLine; &ast; &commat;author Dinesh Rajput&NewLine; &ast;&NewLine; &ast;&sol;&NewLine;public class DrawingApp &NewLine;&lbrace;&NewLine; &sol;&ast;&ast;&NewLine; &ast; &commat;param args&NewLine; &ast;&sol;&NewLine; public static void main&lpar;String&lbrack;&rsqb; args&rpar; &NewLine; &lbrace;&NewLine;ApplicationContext context &equals; new ClassPathXmlApplicationContext&lpar;"spring&period;xml"&rpar;&semi;&NewLine;&NewLine;Point point1 &equals; &lpar;Point&rpar; context&period;getBean&lpar;"zeroPoint"&rpar;&semi;&NewLine;Point point2 &equals; &lpar;Point&rpar; context&period;getBean&lpar;"zeroPoint"&rpar;&semi;&NewLine;if&lpar;point1 &equals;&equals; point2&rpar;&NewLine; System&period;out&period;println&lpar;"In Singleton Demo &gt&semi;&gt&semi; Both are same objects values are&period;&period;" &plus;&NewLine; "n 1&period; point1&equals; "&plus;point1&plus;" n 2&period; point2&equals; "&plus;point2&rpar;&semi;&NewLine;else&NewLine; System&period;out&period;println&lpar;"In Protptype Demo &gt&semi;&gt&semi; Both are different objects values are&period;&period;" &plus;&NewLine; "n 1&period; point1&equals; "&plus;point1&plus;" n 2&period; point2&equals; "&plus;point2&rpar;&semi;&NewLine; &rcub;&NewLine;&rcub;&NewLine;<&sol;pre>&NewLine;<div style&equals;"background-color&colon; &num;ff99cc&semi; border-width&colon; thin&semi; border&colon; solid&semi;">&NewLine;<div style&equals;"color&colon; blue&semi;"><b>Output&colon;<&sol;b><&sol;div>&NewLine;<div style&equals;"color&colon; red&semi;">Jun 28&comma; 2012 9&colon;10&colon;46 PM org&period;springframework&period;context&period;support&period;AbstractApplicationContext prepareRefresh<&sol;div>&NewLine;<div style&equals;"color&colon; red&semi;">INFO&colon; Refreshing org&period;springframework&period;context&period;support&period;ClassPathXmlApplicationContext&commat;ab50cd&colon; startup date &lbrack;Thu Jun 28 21&colon;10&colon;46 IST 2012&rsqb;&semi; root of context hierarchy<&sol;div>&NewLine;<div style&equals;"color&colon; red&semi;">Jun 28&comma; 2012 9&colon;10&colon;46 PM org&period;springframework&period;beans&period;factory&period;xml&period;XmlBeanDefinitionReader loadBeanDefinitions<&sol;div>&NewLine;<div style&equals;"color&colon; red&semi;">INFO&colon; Loading XML bean definitions from class path resource &lbrack;spring&period;xml&rsqb;<&sol;div>&NewLine;<div style&equals;"color&colon; red&semi;">Jun 28&comma; 2012 9&colon;10&colon;46 PM org&period;springframework&period;beans&period;factory&period;support&period;DefaultListableBeanFactory preInstantiateSingletons<&sol;div>&NewLine;<div style&equals;"color&colon; red&semi;">INFO&colon; Pre-instantiating singletons in org&period;springframework&period;beans&period;factory&period;support&period;DefaultListableBeanFactory&commat;1543c88&colon; defining beans &lbrack;zeroPoint&rsqb;&semi; root of factory hierarchy<&sol;div>&NewLine;<p><b>In Singleton Demo &gt&semi;&gt&semi; Both are same objects values are&period;&period;<&sol;b><br &sol;>&NewLine;<b>1&period; point1&equals; com&period;dineshonjava&period;sdnext&period;beanscope&period;tutorial&period;Point&commat;1198891 <&sol;b><br &sol;>&NewLine;<b>2&period; point2&equals; com&period;dineshonjava&period;sdnext&period;beanscope&period;tutorial&period;Point&commat;1198891<&sol;b><&sol;div>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;">&NewLine;Once you are done with creating source and bean configuration files&comma; let us run the application&period; If everything is fine with your application&comma; this will print the above message&colon;<b> See the both address value of the object is same&period;<&sol;b><&sol;div>&NewLine;<div style&equals;"color&colon; blue&semi;"><b>Bean scopes using annotation&colon;<&sol;b><&sol;div>&NewLine;<p><b><br &sol;>&NewLine;<&sol;b> <b>spring&period;xml<&sol;b><&sol;p>&NewLine;<pre class&equals;"highlight" name&equals;"code">&lt&semi;beans xmlns&colon;aop&equals;"http&colon;&sol;&sol;www&period;springframework&period;org&sol;schema&sol;aop" xmlns&colon;context&equals;"http&colon;&sol;&sol;www&period;springframework&period;org&sol;schema&sol;context" xmlns&colon;p&equals;"http&colon;&sol;&sol;www&period;springframework&period;org&sol;schema&sol;p" xmlns&colon;><div style&equals;"color&colon; &num;274e13&semi;"><br &sol;>&NewLine;Here <b>component-scan<&sol;b> element has attribute '<b>base-package<&sol;b>'&period; base-package contain the base package of the Bean class&period;<&sol;div><div style&equals;"color&colon; &num;274e13&semi;"><b><br &sol;>&NewLine;<&sol;b> <b>base-package &equals; "com&period;dineshonjava&period;sdnext&period;beanscope&period;tutorial"<&sol;b><&sol;div><b><br &sol;>&NewLine;<&sol;b> <b>Ponit&period;java<&sol;b><br &sol;>&NewLine;<pre class&equals;"highlight" name&equals;"code">package com&period;dineshonjava&period;sdnext&period;beanscope&period;tutorial&semi;&NewLine;&NewLine;import org&period;springframework&period;context&period;annotation&period;Scope&semi;&NewLine;import org&period;springframework&period;stereotype&period;Service&semi;&NewLine;&NewLine;&commat;Service&NewLine;&commat;Scope&lpar;"singleton"&rpar;&NewLine;public class Point&NewLine;&lbrace;&NewLine; private int x&semi;&NewLine; private int y&semi;&NewLine; &sol;&ast;&ast;&NewLine; &ast; &commat;return the x&NewLine; &ast;&sol;&NewLine; public int getX&lpar;&rpar; &lbrace;&NewLine; return x&semi;&NewLine; &rcub;&NewLine; &sol;&ast;&ast;&NewLine; &ast; &commat;param x the x to set&NewLine; &ast;&sol;&NewLine; public void setX&lpar;int x&rpar; &lbrace;&NewLine; this&period;x &equals; x&semi;&NewLine; &rcub;&NewLine; &sol;&ast;&ast;&NewLine; &ast; &commat;return the y&NewLine; &ast;&sol;&NewLine; public int getY&lpar;&rpar; &lbrace;&NewLine; return y&semi;&NewLine; &rcub;&NewLine; &sol;&ast;&ast;&NewLine; &ast; &commat;param y the y to set&NewLine; &ast;&sol;&NewLine; public void setY&lpar;int y&rpar; &lbrace;&NewLine; this&period;y &equals; y&semi;&NewLine; &rcub;&NewLine;&rcub;&NewLine;<&sol;pre>&NewLine;<div style&equals;"color&colon; blue&semi;"><b><br &sol;>&NewLine;<&sol;b> <b>Annotation &commat;Service&colon;<&sol;b><&sol;div>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;"><b>Target <&sol;b>&colon; Class<&sol;div>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;"><b>Description<&sol;b>&colon;<&sol;div>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;">Here <b>&commat;Service<&sol;b> is streotype annotation which declared above the class name that means this class is a bean of the spring container&period;<&sol;div>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;">In <b>Spring container<&sol;b> this bean recognized by the id "<b>point<&sol;b>" means that <b>same as the class name except first letter of the class name is the small letter<&sol;b>&period;<&sol;div>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;">for example&colon; class '<b>Point<&sol;b>' get as '<b>point<&sol;b>' bean<&sol;div>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;">&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi; class '<b>Circle<&sol;b>' get as '<b>circle<&sol;b>' bean<&sol;p>&NewLine;<div style&equals;"color&colon; blue&semi;"><b>Annotation &commat;Scope&colon;<&sol;b><&sol;div>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;"><b>Target <&sol;b>&colon; Class<&sol;div>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;"><b>Description<&sol;b>&colon;<&sol;div>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;">Here <b>&commat;Scope <&sol;b>is annotation which declared above the class name that define the scope the bean<&sol;div>&NewLine;<p>&nbsp&semi;<b>&commat;Scope&lpar;"singleton"&rpar;<&sol;b><br &sol;>&NewLine;&nbsp&semi;<b>&commat;Scope&lpar;"prototype"&rpar;<&sol;b><b> <&sol;b><br &sol;>&NewLine;<b><br &sol;>&NewLine;<&sol;b><&sol;div>&NewLine;<p><b>DrawingApp&period;java<&sol;b><&sol;p>&NewLine;<pre class&equals;"highlight" name&equals;"code">import org&period;springframework&period;context&period;ApplicationContext&semi;&NewLine;import org&period;springframework&period;context&period;support&period;ClassPathXmlApplicationContext&semi;&NewLine;&NewLine;import com&period;dineshonjava&period;sdnext&period;beanscope&period;tutorial&period;Point&semi;&NewLine;&sol;&ast;&ast;&NewLine; &ast; &commat;author Dinesh Rajput&NewLine; &ast;&NewLine; &ast;&sol;&NewLine;public class DrawingApp &NewLine;&lbrace;&NewLine; &sol;&ast;&ast;&NewLine; &ast; &commat;param args&NewLine; &ast;&sol;&NewLine; public static void main&lpar;String&lbrack;&rsqb; args&rpar; &NewLine; &lbrace;&NewLine;ApplicationContext context &equals; new ClassPathXmlApplicationContext&lpar;"spring&period;xml"&rpar;&semi;&NewLine;Point point1 &equals; &lpar;Point&rpar; context&period;getBean&lpar;"point"&rpar;&semi;&NewLine;Point point2 &equals; &lpar;Point&rpar; context&period;getBean&lpar;"point"&rpar;&semi;&NewLine;if&lpar;point1 &equals;&equals; point2&rpar;&NewLine; System&period;out&period;println&lpar;"In Singleton Demo &gt&semi;&gt&semi; Both are same objects values are&period;&period;" &plus;&NewLine; "n 1&period; point1&equals; "&plus;point1&plus;" n 2&period; point2&equals; "&plus;point2&rpar;&semi;&NewLine;else&NewLine; System&period;out&period;println&lpar;"In Protptype Demo &gt&semi;&gt&semi; Both are different objects values are&period;&period;" &plus;&NewLine; "n 1&period; point1&equals; "&plus;point1&plus;" n 2&period; point2&equals; "&plus;point2&rpar;&semi;&NewLine; &rcub;&NewLine;&rcub;&NewLine;<&sol;pre>&NewLine;<div style&equals;"background-color&colon; &num;ff99cc&semi; border-width&colon; thin&semi; border&colon; solid&semi;">&NewLine;<div style&equals;"color&colon; blue&semi;"><b>Output&colon;<&sol;b><&sol;div>&NewLine;<div style&equals;"color&colon; red&semi;">Jun 28&comma; 2012 10&colon;22&colon;04 PM org&period;springframework&period;context&period;support&period;AbstractApplicationContext prepareRefresh<&sol;div>&NewLine;<div style&equals;"color&colon; red&semi;">INFO&colon; Refreshing org&period;springframework&period;context&period;support&period;ClassPathXmlApplicationContext&commat;145d068&colon; startup date &lbrack;Thu Jun 28 22&colon;22&colon;04 IST 2012&rsqb;&semi; root of context hierarchy<&sol;div>&NewLine;<div style&equals;"color&colon; red&semi;">Jun 28&comma; 2012 10&colon;22&colon;04 PM org&period;springframework&period;beans&period;factory&period;xml&period;XmlBeanDefinitionReader loadBeanDefinitions<&sol;div>&NewLine;<div style&equals;"color&colon; red&semi;">INFO&colon; Loading XML bean definitions from class path resource &lbrack;spring&period;xml&rsqb;<&sol;div>&NewLine;<div style&equals;"color&colon; red&semi;">Jun 28&comma; 2012 10&colon;22&colon;04 PM org&period;springframework&period;beans&period;factory&period;support&period;DefaultListableBeanFactory preInstantiateSingletons<&sol;div>&NewLine;<div style&equals;"color&colon; red&semi;">INFO&colon; Pre-instantiating singletons in org&period;springframework&period;beans&period;factory&period;support&period;DefaultListableBeanFactory&commat;1cbfe9d&colon; defining beans &lbrack;point&comma;org&period;springframework&period;context&period;annotation&period;internalConfigurationAnnotationProcessor&comma;org&period;springframework&period;context&period;annotation&period;internalAutowiredAnnotationProcessor&comma;org&period;springframework&period;context&period;annotation&period;internalRequiredAnnotationProcessor&comma;org&period;springframework&period;context&period;annotation&period;internalCommonAnnotationProcessor&comma;org&period;springframework&period;context&period;annotation&period;ConfigurationClassPostProcessor&dollar;ImportAwareBeanPostProcessor&num;0&rsqb;&semi; root of factory hierarchy<&sol;div>&NewLine;<p><b>In Singleton Demo &gt&semi;&gt&semi; Both are same objects values are&period;&period;<&sol;b><br &sol;>&NewLine;<b>1&period; point1&equals; com&period;dineshonjava&period;sdnext&period;beanscope&period;tutorial&period;Point&commat;84da23 <&sol;b><br &sol;>&NewLine;<b>2&period; point2&equals; com&period;dineshonjava&period;sdnext&period;beanscope&period;tutorial&period;Point&commat;84da23<&sol;b><&sol;div>&NewLine;<&sol;div>&NewLine;<div style&equals;"background-color&colon; &num;f2f9fc&semi; border-radius&colon; 3px&semi; border&colon; 1px solid &num;c9e6f2&semi; line-height&colon; 1&period;45&semi; padding&colon; 16px&semi;"><b>Spring Related Topics you may like<&sol;b><&sol;p>&NewLine;<ol style&equals;"text-align&colon; left&semi;">&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;10&sol;interview-questions-on-spring&period;html">Spring Interview Questions and Answers<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;03&sol;spring-aop-interview-questions-and-answers&period;html">Spring AOP Interview Questions and Answers<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;02&sol;spring-mvc-interview-questions-and-answers&period;html">Spring MVC Interview Questions<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;02&sol;spring-security-interview-questions-and-answers&period;html">Spring Security Interview Questions and Answers<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;03&sol;spring-rest-web-services-interview-questions-and-answers&period;html">Spring REST Interview Questions and Answers<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;04&sol;spring-boot-interview-questions-and-answers&period;html">Spring Boot Interview Questions and Answers<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;04&sol;spring-boot-microservices-interview-questions-answers&period;html">Spring Boot Microservices Interview Questions and Answers<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;06&sol;dependency-injection-in-spring&period;html">Dependency Injection &lpar;DI&rpar; in Spring <&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;06&sol;spring-ioc-container&period;html">Spring IoC Container<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;06&sol;what-is-bean-factory-in-spring&period;html">What is Bean Factory in Spring<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;06&sol;application-context-in-spring&period;html">ApplicationContext in Spring<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;06&sol;bean-autowiring-in-spring&period;html">Bean Autowiring in Spring<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;06&sol;understanding-bean-scopes&period;html">Spring Bean Scopes<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;03&sol;create-custom-bean-scope-in-spring-example&period;html">Create Custom Bean Scope in Spring Example<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;06&sol;using-applicationcontextaware-in-spring&period;html">Using ApplicationContextAware in Spring<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;07&sol;bean-lifecycle-and-callbacks&period;html">Spring Bean Life Cycle and Callbacks<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;07&sol;writing-beanpostprocessor-in-spring&period;html">BeanPostProcessor in Spring<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;07&sol;writing-beanfactorypostprocessor-in&period;html">BeanFactoryPostProcessor in Spring<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;07&sol;annotations-in-spring-and-based&period;html"> Annotations in Spring and Based Configuration<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;07&sol;spring-jsr-250-annotations&period;html">Spring JSR-250 Annotations<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;01&sol;jsr-330-annotations-in-spring&period;html">JSR 330 Annotations in Spring<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;07&sol;stereotype-annotations-in-spring&period;html">Spring &commat;Component&comma; &commat;Repository&comma; &commat;Service and &commat;Controller Stereotype Annotations<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;01&sol;method-injection-with-spring-using-lookup-method-property&period;html">Method injection with Spring using Lookup method property<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;07&sol;introduction-to-aop-in-spring&period;html">Spring AOP-Introduction to Aspect Oriented Programming<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;07&sol;spring-aspect-annotation&period;html">&commat;Aspect Annotation in Spring<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;03&sol;spring-aop-aspectj-before-annotation-advice-example&period;html"> Spring AOP AspectJ &commat;Before Annotation Advice Example<br &sol;>&NewLine;<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;03&sol;spring-aop-before-advice-example-using-xml-config&period;html"> Spring AOP Before Advice Example using XML Config<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;03&sol;spring-aop-aspectj-after-annotation-advice-example&period;html"> Spring AOP AspectJ &commat;After Annotation Advice Example<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;03&sol;spring-aop-after-advice-example-using-xml-config&period;html"> Spring AOP After Advice Example using XML Config<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;03&sol;spring-aop-aspectj-after-returning-annotation-advice-example&period;html"> Spring AOP AspectJ &commat;AfterReturning Annotation Advice Example<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;03&sol;spring-aop-after-returning-advice-example-using-xml-config&period;html"> Spring AOP After-Returning Advice Example using XML Config<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;03&sol;spring-aop-aspectj-after-throwing-annotation-advice-example&period;html"> Spring AOP AspectJ &commat;AfterThrowing Annotation Advice Example<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;03&sol;spring-aop-after-throwing-advice-example-using-xml-config&period;html"> Spring AOP After Throwing Advice Example using XML Config<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;03&sol;spring-aop-aspectj-around-annotation-advice-example&period;html"> Spring AOP AspectJ &commat;Around Annotation Advice Example<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;03&sol;spring-aop-around-advice-example-using-xml-config&period;html"> Spring AOP Around Advice Example using XML Config<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;12&sol;understanding-aop-proxies-chapter-31&period;html">Spring AOP Proxies in Spring<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;12&sol;spring-aop-transaction-management-in&period;html"> Spring AOP Transaction Management in Hibernate<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;12&sol;transaction-management-in-spring&period;html">Spring Transaction Management<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;12&sol;declarative-transaction-management&period;html">Spring Declarative Transaction Management Example<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;03&sol;spring-aop-ordering-of-aspects-with-example&period;html">Spring AOP-Ordering of Aspects with Example<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;02&sol;spring-security-java-based-configuration-with-example&period;html">Spring Security Java Based Configuration with Example<&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2017&sol;02&sol;spring-security-xml-namespace-configuration-example&period;html">Spring Security XML Namespace Configuration Example<&sol;a><&sol;b><&sol;li>&NewLine;<&sol;ol>&NewLine;<&sol;div>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;"><b>&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi;&nbsp&semi; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;2012&sol;06&sol;understanding-bean-scopes&period;html">Bean Scope in The Spring<&sol;a><&sol;b><&sol;div>&NewLine;<&sol;div>&NewLine;<div class&equals;"wp-post-navigation"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <div class&equals;"wp-post-navigation-pre"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-autowiring-by-autodetect&sol;">Previous<&sol;a> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <&sol;div> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <div class&equals;"wp-post-navigation-next"> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;prototype-bean-scope-with-annotation&sol;">Next<&sol;a> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab; <&sol;div> &NewLine;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;&Tab;<&sol;div>&NewLine;<script type&equals;"text&sol;javascript">&NewLine;jQuery&lpar;document&rpar;&period;ready&lpar;function&lpar;&dollar;&rpar; &lbrace;&NewLine; &dollar;&period;post&lpar;'https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-admin&sol;admin-ajax&period;php'&comma; &lbrace;action&colon; 'mts&lowbar;view&lowbar;count'&comma; id&colon; '667'&rcub;&rpar;&semi;&NewLine;&rcub;&rpar;&semi;&NewLine;<&sol;script>

Dinesh Rajput

Dinesh Rajput is the chief editor of a website Dineshonjava, a technical blog dedicated to the Spring and Java technologies. It has a series of articles related to Java technologies. Dinesh has been a Spring enthusiast since 2008 and is a Pivotal Certified Spring Professional, an author of a book Spring 5 Design Pattern, and a blogger. He has more than 10 years of experience with different aspects of Spring and Java design and development. His core expertise lies in the latest version of Spring Framework, Spring Boot, Spring Security, creating REST APIs, Microservice Architecture, Reactive Pattern, Spring AOP, Design Patterns, Struts, Hibernate, Web Services, Spring Batch, Cassandra, MongoDB, and Web Application Design and Architecture. He is currently working as a technology manager at a leading product and web development company. He worked as a developer and tech lead at the Bennett, Coleman & Co. Ltd and was the first developer in his previous company, Paytm. Dinesh is passionate about the latest Java technologies and loves to write technical blogs related to it. He is a very active member of the Java and Spring community on different forums. When it comes to the Spring Framework and Java, Dinesh tops the list!

Share
Published by
Dinesh Rajput

Recent Posts

Strategy Design PatternsĀ using Lambda

Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…

4 years ago

Decorator Pattern using Lambda

Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…

4 years ago

Delegating pattern using lambda

Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…

4 years ago

Spring Vs Django- Know The Difference Between The Two

Technology has emerged a lot in the last decade, and now we have artificial intelligence;…

4 years ago

TOP 20 MongoDB INTERVIEW QUESTIONS 2022

Managing a database is becoming increasingly complex now due to the vast amount of data…

4 years ago

Scheduler @Scheduled Annotation Spring Boot

Overview In this article, we will explore Spring Scheduler how we could use it by…

4 years ago