{"id":92045,"date":"2019-05-23T13:00:45","date_gmt":"2019-05-23T10:00:45","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=92045"},"modified":"2019-05-22T10:58:44","modified_gmt":"2019-05-22T07:58:44","slug":"spring-dependency-injection","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2019\/05\/spring-dependency-injection.html","title":{"rendered":"Spring Dependency Injection"},"content":{"rendered":"<h3 class=\"wp-block-heading\">Introduction:<\/h3>\n<p>In a well-designed Java application, the classes should be as independent as possible. Such a design promotes reusability of components. It also makes it easier to unit test the various components.<\/p>\n<p>The concept of <strong>dependency injection promotes loose coupling among Java objects.<\/strong><\/p>\n<p>In this tutorial, we\u2019ll talk about the dependency injection in Spring framework.<\/p>\n<h3 class=\"wp-block-heading\">Inversion Of Control(IoC):<\/h3>\n<p>Inversion of Control is a software engineering principle which delegates the responsibility of controlling the application\u2019s flow to a framework. To make it possible, <strong>the frameworks use abstractions and rely on object graphs generated at runtime.<\/strong><\/p>\n<p>There are several advantages of using the <em>IoC<\/em> principle:<\/p>\n<ul class=\"wp-block-list\">\n<li>decouples the task implementation from its execution<\/li>\n<li>modules are pluggable and can be easily replaced with their equivalent<\/li>\n<li>eases out the modular testing<\/li>\n<\/ul>\n<p>We can achieve <em>Inversion Of Control<\/em> either by using a Strategy Design Pattern, Service locator Pattern or Dependency Injection.<\/p>\n<h3 class=\"wp-block-heading\">Dependency Injection:<\/h3>\n<p><strong>Dependency Injection is one of the design patterns which allows us to achieve<em> Inversion Of Control.<\/em><\/strong><\/p>\n<p>In a traditional programming style, we\u2019ll have our classes written as:<\/p>\n<pre class=\"brush:java\">\npublic class Person {\n \n    private Address address;\n \n    public Person() {\n        this.address = new Address();\n    }\n \n    ...\n}\n<\/pre>\n<p>When using dependency injection, we\u2019ll not create objects on our own and rather inject them. Our <em>Person<\/em> class would then look something like:<\/p>\n<pre class=\"brush:java\">\npublic class Person {\n \n    private Address address;\n \n    public Person(Address address) {\n        this.address = address;\n    }\n \n    ...\n}\n<\/pre>\n<h3 class=\"wp-block-heading\">Dependency Injection In Spring:<\/h3>\n<p><strong>Spring provides an IoC container which is responsible for instantiating, configuring and managing the lifecycle of Spring beans.<\/strong> In Spring, any POJO is referred to as a Spring bean.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>The Spring <em>ApplicationContext<\/em> interface represents its IoC container and we have several implementation classes available. Some of these include <em>ClassPathXmlApplicationContext<\/em>, <em>FileSystemXmlApplicationContext<\/em>, and <em>WebApplicationContext<\/em>.<\/p>\n<p>Let\u2019s instantiate the Spring container using <em>ClassPathXmlApplicationContext<\/em>:<\/p>\n<pre class=\"brush:java\">\nApplicationContext appContext\n  = new ClassPathXmlApplicationContext(\"applicationContext.xml\");\n<\/pre>\n<p>Here, the <em>applicationContext.xml<\/em> is the file that holds the metadata required to assemble beans at runtime.<\/p>\n<p>Spring supports three types of dependency injection:<\/p>\n<h3 class=\"wp-block-heading\">1. Constructor-Based Injection:<\/h3>\n<p>In a constructor-based injection, Spring will use the matching constructor to resolve and inject the dependency.<\/p>\n<p>We can either configure the beans in <em>applicationContext.xml:<\/em><\/p>\n<pre class=\"brush:xml\">\n&lt;bean id=\"address\" class=\"com.programmergirl.domain.Address\"\/&gt;\n \n&lt;bean id=\"person\" class=\"com.programmergirl.domain.Person\"&gt;\n    &lt;constructor-arg ref=\"address\"\/&gt;\n&lt;\/bean&gt;\n<\/pre>\n<p>Or, we can enable the<em> &lt;component-scan\/&gt; <\/em>in our<em> applicationContext.xml<\/em>:<\/p>\n<pre class=\"brush:xml\">\n&lt;context:component-scan base-package=\"com.programmergirl.domain\" \/&gt;\n<\/pre>\n<p>On enabling component scan, we can make the Spring configurations using the annotations. Our classes would then look like:<\/p>\n<pre class=\"brush:java\">\npackage com.programmergirl.domain;\n@Component\npublic class Person {\n \n    private Address address;\n \n    @Autowired\n    public Person(Address address) {\n        this.address = address;\n    }\n}\n \npackage com.programmergirl.domain;\n@Component\npublic class Address {\n   ...\n}\n<\/pre>\n<p>Spring, by default, wires the beans by their type.<strong> If there are more than one beans of the same type, we can use <em>@Qualifier<\/em> annotation to reference a bean by its name:<\/strong><\/p>\n<pre class=\"brush:java\">\n@Component\npublic class Person {\n \n    private Address address;\n \n    @Autowired\n    @Qualifier(\"address1\")\n    public void setAddress(Address address) {\n        this.address = address;\n    }\n}\n<\/pre>\n<p>Assuming we have two <em>Address<\/em> beans \u2013 <em>address1<\/em> and<em> address2<\/em>, our <em>address1<\/em> bean will be injected into <em>Person<\/em> class while dependency resolution.<\/p>\n<h3 class=\"wp-block-heading\">2. Setter Injection:<\/h3>\n<p>Setter-based dependency injection is achieved through the setter method on the bean after instantiating it using a no-arg constructor or no-argument static factory.<\/p>\n<p>We can configure it using XML as:<\/p>\n<pre class=\"brush:xml\">\n&lt;bean id=\"address\" class=\"com.programmergirl.domain.Address\"\/&gt;\n \n&lt;bean id=\"person\" class=\"com.programmergirl.domain.Person\"&gt;\n    &lt;property name=\"address\" ref=\"address\"\/&gt;\n&lt;\/bean&gt;\n<\/pre>\n<p>On the other hand, when using annotations, we\u2019ll have:<\/p>\n<pre class=\"brush:java\">\n@Component\npublic class Person {\n    \n    private Address address;\n    ...\n    @Autowired\n    public void setAddress(Address address) {\n        this.address = address;\n    }\n    \n}\n<\/pre>\n<h3 class=\"wp-block-heading\">3. Property-Based Injection:<\/h3>\n<p>We can also inject dependencies using fields or properties of a class. To do so, we can simply use the <em>@Autowired<\/em> annotation over the field:<\/p>\n<pre class=\"brush:java\">\n@Component\npublic class Person {\n \n    @Autowired\n    private Address address;\n    ...\n}\n<\/pre>\n<p>considering we\u2019re using annotation based configurations.<\/p>\n<h3 class=\"wp-block-heading\">Noteworthy Points:<\/h3>\n<p>As per Spring documentation:<\/p>\n<ul class=\"wp-block-list\">\n<li>We should <strong>use constructor injection for mandatory dependencies<\/strong><\/li>\n<li>Setter-based injections should be used for dependencies that are optional in nature<\/li>\n<li>Spring uses reflection for injecting the field-injected dependencies. So, field-based injection is a costlier approach and we should avoid using it<\/li>\n<\/ul>\n<h3 class=\"wp-block-heading\">Conclusion:<\/h3>\n<p>In this quick article, we discussed what is dependency injection. We also discussed the types of dependency injection in Spring framework.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>Published on Java Code Geeks with permission by Shubhra Srivastava, partner at our <a href=\"\/\/www.javacodegeeks.com\/join-us\/jcg\/\" target=\"_blank\" rel=\"noopener noreferrer\">JCG program<\/a>. See the original article here: <a href=\"http:\/\/www.programmergirl.com\/spring-dependency-injection\/\" target=\"_blank\" rel=\"noopener noreferrer\">Spring Dependency Injection<\/a><\/p>\n<p>Opinions expressed by Java Code Geeks contributors are their own.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction: In a well-designed Java application, the classes should be as independent as possible. Such a design promotes reusability of components. It also makes it easier to unit test the various components. The concept of dependency injection promotes loose coupling among Java objects. In this tutorial, we\u2019ll talk about the dependency injection in Spring framework. &hellip;<\/p>\n","protected":false},"author":82253,"featured_media":240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[30],"class_list":["post-92045","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-spring"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Spring Dependency Injection - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn about Dependency Injection? Check our article explaining how dependency injection promotes loose coupling among Java objects.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2019\/05\/spring-dependency-injection.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring Dependency Injection - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn about Dependency Injection? Check our article explaining how dependency injection promotes loose coupling among Java objects.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2019\/05\/spring-dependency-injection.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2019-05-23T10:00:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Shubhra Srivastava\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shubhra Srivastava\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/spring-dependency-injection.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/spring-dependency-injection.html\"},\"author\":{\"name\":\"Shubhra Srivastava\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/b73b076dc62e72de203df7018d398e56\"},\"headline\":\"Spring Dependency Injection\",\"datePublished\":\"2019-05-23T10:00:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/spring-dependency-injection.html\"},\"wordCount\":582,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/spring-dependency-injection.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"keywords\":[\"Spring\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/spring-dependency-injection.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/spring-dependency-injection.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/spring-dependency-injection.html\",\"name\":\"Spring Dependency Injection - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/spring-dependency-injection.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/spring-dependency-injection.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"datePublished\":\"2019-05-23T10:00:45+00:00\",\"description\":\"Interested to learn about Dependency Injection? Check our article explaining how dependency injection promotes loose coupling among Java objects.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/spring-dependency-injection.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/spring-dependency-injection.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/spring-dependency-injection.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"spring-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/05\\\/spring-dependency-injection.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Spring Dependency Injection\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/b73b076dc62e72de203df7018d398e56\",\"name\":\"Shubhra Srivastava\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9e5d3b016140986463a886392b8400e55ed0aa7742ef29b86a54bd8d5743b68a?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9e5d3b016140986463a886392b8400e55ed0aa7742ef29b86a54bd8d5743b68a?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9e5d3b016140986463a886392b8400e55ed0aa7742ef29b86a54bd8d5743b68a?s=96&d=mm&r=g\",\"caption\":\"Shubhra Srivastava\"},\"description\":\"Shubhra is a software professional and founder of ProgrammerGirl. She has a great experience with Java\\\/J2EE technologies and frameworks. She loves the amalgam of programming and coffee :)\",\"sameAs\":[\"http:\\\/\\\/www.programmergirl.com\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/shubhra-srivastava224\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/shubhra-srivastava\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring Dependency Injection - Java Code Geeks","description":"Interested to learn about Dependency Injection? Check our article explaining how dependency injection promotes loose coupling among Java objects.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2019\/05\/spring-dependency-injection.html","og_locale":"en_US","og_type":"article","og_title":"Spring Dependency Injection - Java Code Geeks","og_description":"Interested to learn about Dependency Injection? Check our article explaining how dependency injection promotes loose coupling among Java objects.","og_url":"https:\/\/www.javacodegeeks.com\/2019\/05\/spring-dependency-injection.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2019-05-23T10:00:45+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","type":"image\/jpeg"}],"author":"Shubhra Srivastava","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Shubhra Srivastava","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2019\/05\/spring-dependency-injection.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/05\/spring-dependency-injection.html"},"author":{"name":"Shubhra Srivastava","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/b73b076dc62e72de203df7018d398e56"},"headline":"Spring Dependency Injection","datePublished":"2019-05-23T10:00:45+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/05\/spring-dependency-injection.html"},"wordCount":582,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/05\/spring-dependency-injection.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","keywords":["Spring"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2019\/05\/spring-dependency-injection.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2019\/05\/spring-dependency-injection.html","url":"https:\/\/www.javacodegeeks.com\/2019\/05\/spring-dependency-injection.html","name":"Spring Dependency Injection - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/05\/spring-dependency-injection.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/05\/spring-dependency-injection.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","datePublished":"2019-05-23T10:00:45+00:00","description":"Interested to learn about Dependency Injection? Check our article explaining how dependency injection promotes loose coupling among Java objects.","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/05\/spring-dependency-injection.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2019\/05\/spring-dependency-injection.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2019\/05\/spring-dependency-injection.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","width":150,"height":150,"caption":"spring-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2019\/05\/spring-dependency-injection.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Spring Dependency Injection"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/b73b076dc62e72de203df7018d398e56","name":"Shubhra Srivastava","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9e5d3b016140986463a886392b8400e55ed0aa7742ef29b86a54bd8d5743b68a?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/9e5d3b016140986463a886392b8400e55ed0aa7742ef29b86a54bd8d5743b68a?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9e5d3b016140986463a886392b8400e55ed0aa7742ef29b86a54bd8d5743b68a?s=96&d=mm&r=g","caption":"Shubhra Srivastava"},"description":"Shubhra is a software professional and founder of ProgrammerGirl. She has a great experience with Java\/J2EE technologies and frameworks. She loves the amalgam of programming and coffee :)","sameAs":["http:\/\/www.programmergirl.com","https:\/\/www.linkedin.com\/in\/shubhra-srivastava224\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/shubhra-srivastava"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/92045","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/82253"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=92045"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/92045\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/240"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=92045"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=92045"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=92045"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}