Spring Core

Setter vs Constructor Injection in Spring Example

<p>In this article we will discuss Constructor Injection and Setter Injection&period; These are two ways to define the dependency injection in the spring application&period; Spring Dependency Injection &lpar;DI&rpar; design pattern is used to define the object dependencies between each other&period; There are following two types in <b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;dependency-injection-in-spring&sol;">dependency-injection<&sol;a><&sol;b>&colon;<&sol;p>&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<div dir&equals;"ltr" style&equals;"text-align&colon; justify&semi;">&NewLine;<div style&equals;"color&colon; &num;274e13&semi;"><b>1&period; The constructor injection<&sol;b><&sol;div>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;"><b>2&period; The setter injection  <&sol;b><&sol;div>&NewLine;<div id&equals;"ads-id" align&equals;"center"><&sol;div>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;">Historically the <b>setter injection<&sol;b> type come from spring&comma; whereas <b>constructor injection<&sol;b> type are from <b><a href&equals;"http&colon;&sol;&sol;www&period;picocontainer&period;org&sol;">PicoContainer<&sol;a> <&sol;b>and <a href&equals;"http&colon;&sol;&sol;code&period;google&period;com&sol;p&sol;google-guice&sol;"><b>Google GUICE<&sol;b><&sol;a> &lpar;<b><i>Googles <&sol;i><i>lightweight dependency injection framework<&sol;i>&rpar;<&sol;b>&period;<&sol;div>&NewLine;<&sol;div>&NewLine;<p>&nbsp&semi;<&sol;p>&NewLine;<div class&equals;"separator" style&equals;"clear&colon; both&semi; text-align&colon; center&semi;"><img src&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;wp-content&sol;uploads&sol;2012&sol;06&sol;spring-setter-constructor-injections&period;jpg" border&equals;"0" &sol;><&sol;div>&NewLine;<p>&nbsp&semi;<&sol;p>&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;">&NewLine;<p><span style&equals;"color&colon; red&semi; font-size&colon; x-large&semi; text-align&colon; center&semi;"><b>Popular Tutorials<&sol;b><&sol;span><&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;spring-tutorial&sol;"><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;spring-web-mvc-framework-chapter-38&sol;"><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;introduction-to-spring-boot-a-spring-boot-complete-guide&sol;"><strong>Spring Boot Tutorial<&sol;strong> <&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-security-take-baby-step-to-secure&sol;"><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;spring-aop-tutorial-with-example-aspect-advice-pointcut-joinpoint&sol;"><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;using-spring-jdbc-framework-chapter-32&sol;"><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;spring-hateoas-hypermedia-driven-restful-web-service&sol;"><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;microservices-with-spring-boot&sol;"><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;jax-rs-web-service-tutorial&sol;"><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;core-java-baby-step-to-be-best-java-ian&sol;"><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;hibernate-3-on-baby-steps&sol;"><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;spring-batch-process-with-example&sol;"><strong><em>Spring Batch<&sol;em> <&sol;strong><&sol;a><&sol;b><&sol;li>&NewLine;<&sol;ul>&NewLine;<&sol;div>&NewLine;<p>&nbsp&semi;<&sol;p>&NewLine;<h2 style&equals;"color&colon; &num;274e13&semi;"><b>Constructor Injection<&sol;b><&sol;h2>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;">The basic idea with <b>constructor injection<&sol;b> is that the object has no defaults and instead you have a single constructor where all of the collaborators and values need to be supplied before you can instantiate the object&period;<&sol;div>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;">Now we see an Example which has Constructor Injection type dependency&period;<&sol;div>&NewLine;<p><b>Triangle&period;java<&sol;b><&sol;p>&NewLine;<pre class&equals;"highlight">package com&period;dineshonjava&period;sdnext&period;constructorInjection&period;tutorial&semi; &NewLine; &NewLine;&sol;&ast;&ast; &NewLine; &ast; &commat;author Dinesh Rajput &NewLine; &ast; &NewLine; &ast;&sol; &NewLine;public class Triangle &NewLine;&lbrace; &NewLine; private String type&semi; &NewLine; private int height&semi; &NewLine; &sol;&ast;&ast; &NewLine; &ast; &commat;param type the type to set &NewLine; &ast;&sol; &NewLine; &sol;&ast;public void setType&lpar;String type&rpar; &lbrace; &NewLine; this&period;type &equals; type&semi; &NewLine; &rcub;&ast;&sol; &NewLine; &NewLine; public Triangle&lpar;String type&rpar; &NewLine; &lbrace; &NewLine; this&period;type &equals; type&semi; &NewLine; &rcub; &NewLine; public Triangle&lpar;int height&rpar; &NewLine; &lbrace; &NewLine; this&period;height &equals; height&semi; &NewLine; &rcub; &NewLine; public Triangle&lpar;String type&comma; int height&rpar; &NewLine; &lbrace; &NewLine; this&period;type &equals; type&semi; &NewLine; this&period;height &equals; height&semi; &NewLine; &rcub; &NewLine; public void draw&lpar;&rpar; &NewLine; &lbrace; &NewLine; System&period;out&period;println&lpar;this&period;type&plus;" triangle is drawn of height "&plus;this&period;height&rpar;&semi; &NewLine; &rcub; &NewLine;&rcub; &NewLine;<&sol;pre>&NewLine;<p>The <i style&equals;"color&colon; &num;274e13&semi;"><b>Triangle<&sol;b><&sol;i> bean class has two attributes viz&period;<i style&equals;"color&colon; &num;274e13&semi;"> <b>type <&sol;b>and <b>height<&sol;b><&sol;i>&period; All the two attributes are set using the <b>constructor injection<&sol;b>&period;<b> <&sol;b><br &sol;>&NewLine;<b>spring&period;xml<&sol;b><&sol;p>&NewLine;<pre class&equals;"highlight">&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;> &NewLine;<div style&equals;"color&colon; &num;274e13&semi;">The <b><i>id<&sol;i> <&sol;b>attribute of the <b><i>bean<&sol;i> <&sol;b>element is used to specify the bean name and the <b><i>class<&sol;i> <&sol;b>attribute is used to specify the <b>fully qualified class name of the bean<&sol;b>&period; The <i><b>constructor-arg<&sol;b><&sol;i> element with in the <b><i>bean<&sol;i> <&sol;b>element is used to<b> inject property value via constructor injection<&sol;b>&period; The <i><b>index<&sol;b><&sol;i> attribute of the <i><b>constructor-arg<&sol;b><&sol;i> element represents the constructor argument sequences which passes to the constructor of the class &NewLine;such as&period;&period; <b> <&sol;b> &NewLine;<b>      Triangle&lpar;String type&comma; int height&rpar;<&sol;b> &NewLine;at <b>index &equals; 0 <&sol;b>argument is<b> type&semi;<&sol;b> &NewLine;and at <b>index &equals; 1<&sol;b> argument is<b> height&semi;<&sol;b> &NewLine;<b>      and so on&period;<&sol;b> &NewLine;<b> <&sol;b>If any class has <b>one argument constructor<&sol;b> then<b> there are no need to specify the index attribute<&sol;b> of the bean in the bean configuration in spring&period;<b> i&period;e&period; We can say index attribute used to distinguished to arguments of the constructor&period; <&sol;b>Now second attribute is <b>type<&sol;b> of the <i><b>constructor-arg <&sol;b><&sol;i>it is used for type of the arguments of the constructor&period; &NewLine;Such as&period;&period; &NewLine;<b>          Triangle&lpar;String type&comma; int height&rpar;<&sol;b> &NewLine;then <b>type <&sol;b><b>&equals; "java&period;lang&period;String"<&sol;b> &NewLine;<b>         and <&sol;b><b>type <&sol;b><b>&equals; "int"<&sol;b> &NewLine;and the <b><i>value<&sol;i> <&sol;b>attribute specifies the corresponding<b> property value<&sol;b>&period;<&sol;div> &NewLine;<div style&equals;"color&colon; &num;274e13&semi;"><&sol;div> &NewLine;<div style&equals;"color&colon; &num;274e13&semi;">Here we set "<i><b>Equilateral <&sol;b><&sol;i>" and "<i><b>20<&sol;b><&sol;i>" for the <i><b>Triangle<&sol;b><&sol;i> bean properties <b><i>type <&sol;i>and <i>height<&sol;i><&sol;b> respectively&period; The following <i>Main<&sol;i> class is used to get the <i><b>Triangle<&sol;b><&sol;i> bean from the <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-ioc-container&sol;"><b>Spring IoC container<&sol;b><&sol;a> and display its value it to the<i><b> Triangle<&sol;b><&sol;i>  &period;<&sol;div> &NewLine;<b>DrawingApp&period;java<&sol;b> &NewLine;<pre class&equals;"highlight">package com&period;dineshonjava&period;sdnext&period;constructorInjection&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; &sol;&sol;Triangle triangle &equals; new Triangle&lpar;&rpar;&semi; &NewLine; &sol;&sol;BeanFactory factory &equals;new XmlBeanFactory&lpar;new FileSystemResource&lpar;"spring&period;xml"&rpar;&rpar;&semi; &NewLine; ApplicationContext context &equals; new ClassPathXmlApplicationContext&lpar;"spring&period;xml"&rpar;&semi; &NewLine; Triangle triangle &equals; &lpar;Triangle&rpar; context&period;getBean&lpar;"triangle"&rpar;&semi; &NewLine; triangle&period;draw&lpar;&rpar;&semi; &NewLine; &rcub; &NewLine;&rcub; &NewLine;<&sol;pre>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;"><b>Now we run this example the following output on the console&period;<&sol;b><&sol;div>&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 20&comma; 2012 12&colon;12&colon;25 AM 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;Wed Jun 20 00&colon;12&colon;25 IST 2012&rsqb;&semi; root of context hierarchy<&sol;div>&NewLine;<div style&equals;"color&colon; red&semi;">Jun 20&comma; 2012 12&colon;12&colon;25 AM 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 20&comma; 2012 12&colon;12&colon;26 AM 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;14c1103&colon; defining beans &lbrack;triangle&rsqb;&semi; root of factory hierarchy<&sol;div>&NewLine;<p><b>Equilateral triangle is drawn of height 20<&sol;b><&sol;p>&NewLine;<&sol;div>&NewLine;<&sol;div>&NewLine;<div><&sol;div>&NewLine;<h2 style&equals;"color&colon; &num;274e13&semi;"><b>Setter Injection<&sol;b><&sol;h2>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;">The basic-ideas is that you have a no <b>argument-constructor<&sol;b> which creates the object with <b>reasonable-defaults<&sol;b> &period; The user of the object can then call <b>setters <&sol;b>on the object to override the collaborators of the object in order to wire the object graph together or to replace the key collaborators with test-doubles&period;<&sol;div>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;">Now we see an Example which has Constructor Injection type dependency&period;<&sol;div>&NewLine;<p><b>Triangle&period;java<&sol;b><&sol;p>&NewLine;<pre class&equals;"highlight">package com&period;sdnext&period;constructorInjection&period;tutorial&semi; &NewLine; &NewLine;&sol;&ast;&ast; &NewLine; &ast; &commat;author Dinesh Rajput &NewLine; &ast; &NewLine; &ast;&sol; &NewLine;public class Triangle &NewLine;&lbrace; &NewLine; private String type&semi; &NewLine; private int height&semi; &NewLine; &sol;&ast;&ast; &NewLine; &ast; &commat;param type the type to set &NewLine; &ast;&sol; &NewLine; public void setType&lpar;String type&rpar; &lbrace; &NewLine; this&period;type &equals; type&semi; &NewLine; &rcub; &NewLine; &NewLine; &sol;&ast;&ast; &NewLine; &ast; &commat;param height the height to set &NewLine; &ast;&sol; &NewLine; public void setHeight&lpar;String height&rpar; &lbrace; &NewLine; this&period;height&equals; height&semi; &NewLine; &rcub; &NewLine; &NewLine; public void draw&lpar;&rpar; &NewLine; &lbrace; &NewLine; System&period;out&period;println&lpar;this&period;type&plus;" triangle is drawn of height "&plus;this&period;height&rpar;&semi; &NewLine; &rcub; &NewLine;&rcub; &NewLine; &NewLine;<&sol;pre>&NewLine;<p>The <i style&equals;"color&colon; &num;274e13&semi;"><b>Triangle<&sol;b><&sol;i> bean class has two attributes viz&period;<i style&equals;"color&colon; &num;274e13&semi;"> <b>type and height<&sol;b><&sol;i>&period; All the two attributes are set using the <b>setter injection<&sol;b>&period; <b><br &sol;>&NewLine;<&sol;b><&sol;p>&NewLine;<p><b>spring&period;xml<&sol;b><&sol;p>&NewLine;<pre class&equals;"highlight">&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;> &NewLine;<div style&equals;"color&colon; &num;274e13&semi;">The <b><i>id<&sol;i> <&sol;b>attribute of the <b><i>bean<&sol;i> <&sol;b>element is used to specify the bean name and the <b><i>class<&sol;i> <&sol;b>attribute is used to specify the <b>fully qualified class name of the bean<&sol;b>&period; The <b><i>property<&sol;i> <&sol;b>element with in the <b><i>bean<&sol;i> <&sol;b>element is used to<b> inject property value via setter injection<&sol;b>&period; The <b><i>name<&sol;i> <&sol;b>attribute of the <b><i>property<&sol;i> <&sol;b>element represents the bean attribute and the <b><i>value<&sol;i> <&sol;b>attribute specifies the corresponding<b> property value<&sol;b>&period;<&sol;div> &NewLine;<div style&equals;"color&colon; &num;274e13&semi;"><&sol;div> &NewLine;<div style&equals;"color&colon; &num;274e13&semi;">Here we set "<i><b>Equilateral <&sol;b><&sol;i>" and "<i><b>20<&sol;b><&sol;i>" for the <i><b>Triangle<&sol;b><&sol;i> bean properties <b><i>type <&sol;i>and <i>height<&sol;i><&sol;b> respectively&period; The following <i>Main<&sol;i> class is used to get the <i><b>Triangle<&sol;b><&sol;i> bean from the <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-ioc-container&sol;"><b>Spring IoC container<&sol;b><&sol;a> and display its value it to the<i><b> Triangle<&sol;b><&sol;i>  &period;<&sol;div> &NewLine;<b> <&sol;b> &NewLine;<b>DrawingApp&period;java<&sol;b> &NewLine;<pre class&equals;"highlight">package com&period;dineshonjava&period;sdnext&period;constructorInjection&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; &sol;&sol;Triangle triangle &equals; new Triangle&lpar;&rpar;&semi; &NewLine; &sol;&sol;BeanFactory factory &equals;new XmlBeanFactory&lpar;new FileSystemResource&lpar;"spring&period;xml"&rpar;&rpar;&semi; &NewLine; ApplicationContext context &equals; new ClassPathXmlApplicationContext&lpar;"spring&period;xml"&rpar;&semi; &NewLine; Triangle triangle &equals; &lpar;Triangle&rpar; context&period;getBean&lpar;"triangle"&rpar;&semi; &NewLine; triangle&period;draw&lpar;&rpar;&semi; &NewLine; &rcub; &NewLine;&rcub; &NewLine;<&sol;pre>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;"><b>Now we run this example the following output on the console&period;<&sol;b><&sol;div>&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 20&comma; 2012 12&colon;12&colon;25 AM 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;Wed Jun 20 00&colon;12&colon;25 IST 2012&rsqb;&semi; root of context hierarchy<&sol;div>&NewLine;<div style&equals;"color&colon; red&semi;">Jun 20&comma; 2012 12&colon;12&colon;25 AM 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 20&comma; 2012 12&colon;12&colon;26 AM 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;14c1103&colon; defining beans &lbrack;triangle&rsqb;&semi; root of factory hierarchy<&sol;div>&NewLine;<p><b>Equilateral triangle is drawn of height 20<&sol;b><&sol;p>&NewLine;<&sol;div>&NewLine;<&sol;div>&NewLine;<h2 style&equals;"color&colon; &num;274e13&semi;">Injecting Object&lpar;User define&rpar; to the Bean<&sol;h2>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;">In the above examples we have been seen that how to define the<i><b> bean&lpar;Triangle&rpar;<&sol;b><&sol;i> definition in the <b><i>configuration file &lpar;spring&period;xml&rpar;<&sol;i><&sol;b> and initialized its associated <b><i>properties&lpar;type and height&rpar;<&sol;i><&sol;b>&period; In previous examples We only used <b>primitive data types &lpar;int&comma; long&comma; double etc&period;&rpar;<&sol;b> and <b>java defined class such as like String&comma; Integer&comma; etc&lpar;for example type is String and height is int&rpar;<&sol;b>&period;<&sol;div>&NewLine;<pre class&equals;"highlight">pubic class Triangle&lbrace; &NewLine; private int height&semi; &NewLine; private String type&semi; &NewLine; private double area&semi; &NewLine; &period;&period;&period; &NewLine; &period;&period;&period; &NewLine;&rcub; &NewLine;<&sol;pre>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;">Now we will define a <i><b>bean&lpar;Triangle&rpar; <&sol;b><&sol;i>with user define <b>properties &lpar;Point class&rpar;<&sol;b>&period;<&sol;div>&NewLine;<pre class&equals;"highlight">pubic class Triangle&lbrace; &NewLine; private Point pointA&semi; &NewLine; private Point pointB&semi; &NewLine; private Point pointC&semi; &NewLine; &period;&period;&period; &NewLine; &period;&period;&period; &NewLine;&rcub;<&sol;pre>&NewLine;<pre class&equals;"highlight">pubic class Point&lbrace; &NewLine; private int X&semi; &NewLine; private int Y&semi; &NewLine; &period;&period;&period; &NewLine; &period;&period;&period; &NewLine;&rcub;<&sol;pre>&NewLine;<&sol;div>&NewLine;<p>Lets see with the example&period; <b> <&sol;b><br &sol;>&NewLine;<b>Triangle&period;java<&sol;b><&sol;p>&NewLine;<pre class&equals;"highlight">package com&period;dineshonjava&period;sdnext&period;injectingObject&period;tutorial&semi; &NewLine; &NewLine;public class Triangle &NewLine;&lbrace; &NewLine; private Point pointA&semi; &NewLine; private Point pointB&semi; &NewLine; private Point pointC&semi; &NewLine; &NewLine; &sol;&ast;&ast; &NewLine; &ast; &commat;param pointA the pointA to set &NewLine; &ast;&sol; &NewLine; public void setPointA&lpar;Point pointA&rpar; &lbrace; &NewLine; this&period;pointA &equals; pointA&semi; &NewLine; &rcub; &NewLine; &NewLine; &sol;&ast;&ast; &NewLine; &ast; &commat;param pointB the pointB to set &NewLine; &ast;&sol; &NewLine; public void setPointB&lpar;Point pointB&rpar; &lbrace; &NewLine; this&period;pointB &equals; pointB&semi; &NewLine; &rcub; &NewLine; &NewLine; &sol;&ast;&ast; &NewLine; &ast; &commat;param pointC the pointC to set &NewLine; &ast;&sol; &NewLine; public void setPointC&lpar;Point pointC&rpar; &lbrace; &NewLine; this&period;pointC &equals; pointC&semi; &NewLine; &rcub; &NewLine; &NewLine; public void draw&lpar;&rpar; &NewLine; &lbrace; &NewLine; System&period;out&period;println&lpar;"PointA is &lpar;"&plus;pointA&period;getX&lpar;&rpar;&plus;"&comma; "&plus;pointA&period;getY&lpar;&rpar;&plus;"&rpar;"&rpar;&semi; &NewLine; System&period;out&period;println&lpar;"PointB is &lpar;"&plus;pointB&period;getX&lpar;&rpar;&plus;"&comma; "&plus;pointB&period;getY&lpar;&rpar;&plus;"&rpar;"&rpar;&semi; &NewLine; System&period;out&period;println&lpar;"PointC is &lpar;"&plus;pointC&period;getX&lpar;&rpar;&plus;"&comma; "&plus;pointC&period;getY&lpar;&rpar;&plus;"&rpar;"&rpar;&semi; &NewLine; &rcub; &NewLine;&rcub; &NewLine;<&sol;pre>&NewLine;<div style&equals;"color&colon; &num;274e13&semi;"><b>Triangle <&sol;b>class has three points of nodes to draw a triangle and define setter of all three points pointA&comma; pointB and pointC &lpar;<b>only setter is required in the spring framework<&sol;b>&rpar;&period; Here point is also a class with two points one is X-axis and another is Y-axis&period;<&sol;div>&NewLine;<p><b>Point&period;java<&sol;b><&sol;p>&NewLine;<pre class&equals;"highlight">package com&period;dineshonjava&period;sdnext&period;injectingObject&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>Here we define the <b>Point <&sol;b>class with two properties<b> int x&comma; int y&period;<&sol;b> Actually <b>Point <&sol;b>class is also a bean which is as a<b> property of the Triangle bean<&sol;b>&period; Now we will configure both beans to the configuration file&lpar;<b>spring&period;xml<&sol;b>&rpar;&period;<br &sol;>&NewLine;<b>spring&period;xml<&sol;b><&sol;p>&NewLine;<pre class&equals;"highlight">&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;> &NewLine;<div style&equals;"color&colon; &num;274e13&semi;">The <b><i>id<&sol;i> <&sol;b>attribute of the <b><i>bean<&sol;i> <&sol;b>element is used to specify the bean name and the <b><i>class<&sol;i> <&sol;b>attribute is used to specify the <b>fully qualified class name of the bean<&sol;b>&period; The <b><i>property<&sol;i> <&sol;b>element with in the <b><i>bean<&sol;i> <&sol;b>element is used to<b> inject property value via setter injection<&sol;b>&period; The <b><i>name<&sol;i> <&sol;b>attribute of the <b><i>property<&sol;i> <&sol;b>element represents the bean attribute and the <i><b>ref<&sol;b><&sol;i> attribute specifies the reference of another bean or <i><b>id<&sol;b><&sol;i> of the <b><i>bean<&sol;i> <&sol;b>element &lpar;Point&rpar;  corresponding<b> property<&sol;b>&period;<&sol;div> &NewLine;<div style&equals;"color&colon; &num;274e13&semi;"><&sol;div> &NewLine;<div style&equals;"color&colon; &num;274e13&semi;">Here we set "<i><b>pointA<&sol;b><&sol;i>"&comma; "<i><b>pointB<&sol;b><&sol;i>" and "<i><b>pointC<&sol;b><&sol;i>" properties name for the <i><b>Triangle<&sol;b><&sol;i> bean with <i><b>ref<&sol;b><&sol;i> <i><b>id<&sol;b><&sol;i> of another bean &lpar;Point&rpar; "<i><b>pointA<&sol;b><&sol;i>"&comma; "<i><b>pointB<&sol;b><&sol;i>" and "<i><b>pointC<&sol;b><&sol;i>" &lpar;these <i><b>id<&sol;b><&sol;i> name may be different such like "<i><b>point1<&sol;b><&sol;i>"&comma; "<i><b>point2<&sol;b><&sol;i>" and "<i><b>point3<&sol;b><&sol;i>"&rpar; respectively&period; Now "<i><b>pointA<&sol;b><&sol;i>" is the id of bean element of one Point class and so on&period; The following <i>Main<&sol;i> class is used to get the <i><b>Triangle<&sol;b><&sol;i> bean from the <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-ioc-container&sol;"><b>Spring IoC container<&sol;b><&sol;a> and display its value it to the<i><b> Triangle<&sol;b><&sol;i>  &period;<&sol;div> &NewLine;&nbsp&semi; &NewLine; &NewLine;<b>DrawingApp&period;java<&sol;b> &NewLine;<pre class&equals;"highlight">package com&period;dineshonjava&period;sdnext&period;injectingObject&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; &sol;&sol;BeanFactory factory &equals;new XmlBeanFactory&lpar;new FileSystemResource&lpar;"spring&period;xml"&rpar;&rpar;&semi; &NewLine; ApplicationContext context &equals; new ClassPathXmlApplicationContext&lpar;"spring&period;xml"&rpar;&semi; &NewLine; Triangle triangle &equals; &lpar;Triangle&rpar; context&period;getBean&lpar;"triangle"&rpar;&semi; &NewLine; triangle&period;draw&lpar;&rpar;&semi; &NewLine; &rcub; &NewLine;&rcub;<&sol;pre>&NewLine;<p>&nbsp&semi;<&sol;p>&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 23&comma; 2012 12&colon;30&colon;25 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;Sat Jun 23 12&colon;30&colon;25 IST 2012&rsqb;&semi; root of context hierarchy<&sol;div>&NewLine;<div style&equals;"color&colon; red&semi;">Jun 23&comma; 2012 12&colon;30&colon;26 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 23&comma; 2012 12&colon;30&colon;26 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;14c1103&colon; defining beans &lbrack;triangle&comma;zeroPoint&comma;Point2&comma;Point3&rsqb;&semi; root of factory hierarchy<&sol;div>&NewLine;<p><b>PointA is &lpar;0&comma; 0&rpar;<&sol;b><br &sol;>&NewLine;<b>PointB is &lpar;-20&comma; 0&rpar;<&sol;b><br &sol;>&NewLine;<b>PointC is &lpar;20&comma; 0&rpar;<&sol;b><&sol;p>&NewLine;<&sol;div>&NewLine;<&sol;div>&NewLine;<p>&nbsp&semi;<&sol;p>&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;">&NewLine;<p><span style&equals;"color&colon; red&semi; font-size&colon; x-large&semi; text-align&colon; center&semi;"><b>Spring Related Topics you may like<&sol;b><&sol;span><&sol;p>&NewLine;<ul>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;interview-questions-on-spring&sol;"><span style&equals;"color&colon; red&semi;">Spring Interview Questions and Answers<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-interview-questions-and-answers&sol;"><span style&equals;"color&colon; red&semi;">Spring AOP Interview Questions and Answers<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-mvc-interview-questions-and-answers&sol;"><span style&equals;"color&colon; red&semi;">Spring MVC Interview Questions<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-security-interview-questions-and-answers&sol;"><span style&equals;"color&colon; red&semi;">Spring Security Interview Questions and Answers<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-rest-web-services-interview-questions-and-answers&sol;"><span style&equals;"color&colon; red&semi;">Spring REST Interview Questions and Answers<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-interview-questions-and-answers&sol;"><span style&equals;"color&colon; red&semi;">Spring Boot Interview Questions and Answers<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-boot-microservices-interview-questions-answers&sol;"><span style&equals;"color&colon; red&semi;">Spring Boot Microservices Interview Questions and Answers<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;dependency-injection-in-spring&sol;"><span style&equals;"color&colon; red&semi;">Dependency Injection &lpar;DI&rpar; in Spring <&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-ioc-container&sol;"><span style&equals;"color&colon; red&semi;">Spring IoC Container<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;what-is-bean-factory-in-spring&sol;"><span style&equals;"color&colon; red&semi;">What is Bean Factory in Spring<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;application-context-in-spring&sol;"><span style&equals;"color&colon; red&semi;">ApplicationContext in Spring<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;bean-autowiring-in-spring&sol;"><span style&equals;"color&colon; red&semi;">Bean Autowiring in Spring<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;understanding-bean-scopes&sol;"><span style&equals;"color&colon; red&semi;">Spring Bean Scopes<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;create-custom-bean-scope-in-spring-example&sol;"><span style&equals;"color&colon; red&semi;">Create Custom Bean Scope in Spring Example<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;using-applicationcontextaware-in-spring&sol;"><span style&equals;"color&colon; red&semi;">Using ApplicationContextAware in Spring<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;bean-lifecycle-and-callbacks&sol;"><span style&equals;"color&colon; red&semi;">Spring Bean Life Cycle and Callbacks<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;writing-beanpostprocessor-in-spring&sol;"><span style&equals;"color&colon; red&semi;">BeanPostProcessor in Spring<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;writing-beanfactorypostprocessor-in&sol;"><span style&equals;"color&colon; red&semi;">BeanFactoryPostProcessor in Spring<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;annotations-in-spring-and-based&sol;"><span style&equals;"color&colon; red&semi;"> Annotations in Spring and Based Configuration<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-jsr-250-annotations&sol;"><span style&equals;"color&colon; red&semi;">Spring JSR-250 Annotations<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;jsr-330-annotations-in-spring&sol;"><span style&equals;"color&colon; red&semi;">JSR 330 Annotations in Spring<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;stereotype-annotations-in-spring&sol;"><span style&equals;"color&colon; red&semi;">Spring &commat;Component&comma; &commat;Repository&comma; &commat;Service and &commat;Controller Stereotype Annotations<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;method-injection-with-spring-using-lookup-method-property&sol;"><span style&equals;"color&colon; red&semi;">Method injection with Spring using Lookup method property<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;introduction-to-aop-in-spring&sol;"><span style&equals;"color&colon; red&semi;">Spring AOP-Introduction to Aspect Oriented Programming<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aspect-annotation&sol;"><span style&equals;"color&colon; red&semi;">&commat;Aspect Annotation in Spring<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-aspectj-before-annotation-advice-example&sol;"><span style&equals;"color&colon; red&semi;"> Spring AOP AspectJ &commat;Before Annotation Advice Example<br &sol;>&NewLine;<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-before-advice-example-using-xml-config&sol;"><span style&equals;"color&colon; red&semi;"> Spring AOP Before Advice Example using XML Config<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-aspectj-after-annotation-advice-example&sol;"><span style&equals;"color&colon; red&semi;"> Spring AOP AspectJ &commat;After Annotation Advice Example<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-after-advice-example-using-xml-config&sol;"><span style&equals;"color&colon; red&semi;"> Spring AOP After Advice Example using XML Config<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-aspectj-after-returning-annotation-advice-example&sol;"><span style&equals;"color&colon; red&semi;"> Spring AOP AspectJ &commat;AfterReturning Annotation Advice Example<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-after-returning-advice-example-using-xml-config&sol;"><span style&equals;"color&colon; red&semi;"> Spring AOP After-Returning Advice Example using XML Config<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-aspectj-after-throwing-annotation-advice-example&sol;"><span style&equals;"color&colon; red&semi;"> Spring AOP AspectJ &commat;AfterThrowing Annotation Advice Example<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-after-throwing-advice-example-using-xml-config&sol;"><span style&equals;"color&colon; red&semi;"> Spring AOP After Throwing Advice Example using XML Config<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-aspectj-around-annotation-advice-example&sol;"><span style&equals;"color&colon; red&semi;"> Spring AOP AspectJ &commat;Around Annotation Advice Example<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-around-advice-example-using-xml-config&sol;"><span style&equals;"color&colon; red&semi;"> Spring AOP Around Advice Example using XML Config<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;understanding-aop-proxies-chapter-31&sol;"><span style&equals;"color&colon; red&semi;">Spring AOP Proxies in Spring<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-transaction-management-in&sol;"><span style&equals;"color&colon; red&semi;"> Spring AOP Transaction Management in Hibernate<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;transaction-management-in-spring&sol;"><span style&equals;"color&colon; red&semi;">Spring Transaction Management<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;declarative-transaction-management&sol;"><span style&equals;"color&colon; red&semi;">Spring Declarative Transaction Management Example<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-aop-ordering-of-aspects-with-example&sol;"><span style&equals;"color&colon; red&semi;">Spring AOP-Ordering of Aspects with Example<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-security-java-based-configuration-with-example&sol;"><span style&equals;"color&colon; red&semi;">Spring Security Java Based Configuration with Example<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<li><b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;spring-security-xml-namespace-configuration-example&sol;"><span style&equals;"color&colon; red&semi;">Spring Security XML Namespace Configuration Example<&sol;span><&sol;a><&sol;b><&sol;li>&NewLine;<&sol;ul>&NewLine;<p>&nbsp&semi;<&sol;p>&NewLine;<&sol;div>&NewLine;<p><b>In <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;injecting-inner-beans-in-spring-with&sol;">Next Chapter<&sol;a> we will discuss about <&sol;b><a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;injecting-inner-beans-in-spring-with&sol;"><b>Injecting Inner Beans in Spring with Example<&sol;b><&sol;a><b> in Application&period;<&sol;b><&sol;p>&NewLine;<p><b>                                          <&sol;b><br &sol;>&NewLine;<b>                                                    &lt&semi;&lt&semi; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;application-context-in-spring&sol;">Previous<&sol;a> &vert;&vert; <a href&equals;"https&colon;&sol;&sol;dineshonjava&period;com&sol;injecting-inner-beans-in-spring-with&sol;">Next<&sol;a> &gt&semi;&gt&semi; <&sol;b><br &sol;>&NewLine;<b><br &sol;>&NewLine;<&sol;b> <b><br &sol;>&NewLine;<&sol;b><&sol;p>&NewLine;<&sol;div>&NewLine;<p>&nbsp&semi;<&sol;p>&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;application-context-in-spring&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;injecting-inner-beans-in-spring-with&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; '676'&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