{"id":586,"date":"2011-09-03T10:00:00","date_gmt":"2011-09-03T10:00:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/the-evolution-of-spring-dependency-injection-techniques.html"},"modified":"2012-10-21T20:20:58","modified_gmt":"2012-10-21T20:20:58","slug":"evolution-of-spring-dependency","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2011\/09\/evolution-of-spring-dependency.html","title":{"rendered":"The evolution of Spring dependency injection techniques"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\">Looking back at the history of Spring framework you will find out that the number of ways you can implement dependency injection is growing in every release.<\/p>\n<p>If you&#8217;ve been working with this framework for more than a month you&#8217;ll probably find nothing interesting in this retrospective article. Nothing hopefully except the last example in Scala, language that accidentally works great with Spring.<\/p>\n<p><strong>First there was XML<\/strong> [<a href=\"https:\/\/github.com\/nurkiewicz\/spring-di\/tree\/xml\">full source<\/a>]:<\/p>\n<pre class=\"brush:xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;beans xmlns=\"http:\/\/www.springframework.org\/schema\/beans\"\r\n       xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\r\n       xsi:schemaLocation=\"http:\/\/www.springframework.org\/schema\/beans http:\/\/www.springframework.org\/schema\/beans\/spring-beans-3.1.xsd \"&gt;\r\n\r\n    &lt;bean id=\"foo\" class=\"com.blogspot.nurkiewicz.Foo\"&gt;\r\n        &lt;property name=\"bar\" ref=\"bar\"\/&gt;\r\n        &lt;property name=\"jdbcOperations\" ref=\"jdbcTemplate\"\/&gt;\r\n    &lt;\/bean&gt;\r\n\r\n    &lt;bean id=\"bar\" class=\"com.blogspot.nurkiewicz.Bar\" init-method=\"init\"\/&gt;\r\n\r\n    &lt;bean id=\"dataSource\" class=\"org.apache.commons.dbcp.BasicDataSource\"&gt;\r\n        &lt;property name=\"driverClassName\" value=\"org.h2.Driver\"\/&gt;\r\n        &lt;property name=\"url\" value=\"jdbc:h2:mem:\"\/&gt;\r\n        &lt;property name=\"username\" value=\"sa\"\/&gt;\r\n    &lt;\/bean&gt;\r\n\r\n    &lt;bean id=\"jdbcTemplate\" class=\"org.springframework.jdbc.core.JdbcTemplate\"&gt;\r\n        &lt;constructor-arg ref=\"dataSource\"\/&gt;\r\n    &lt;\/bean&gt;\r\n&lt;\/beans&gt; \r\n<\/pre>\n<p>This simple application only fetches H2 database server time and prints it with full formatting:<\/p>\n<pre class=\"brush:java\">public class Foo {\r\n\r\n    private Bar bar;\r\n\r\n    private JdbcOperations jdbcOperations;\r\n\r\n    public String serverTime() {\r\n        return bar.format(\r\n                jdbcOperations.queryForObject(\"SELECT now()\", Date.class)\r\n        );\r\n    }\r\n\r\n    public void setBar(Bar bar) {\r\n        this.bar = bar;\r\n    }\r\n\r\n    public void setJdbcOperations(JdbcOperations jdbcOperations) {\r\n        this.jdbcOperations = jdbcOperations;\r\n    }\r\n}\r\n<\/pre>\n<pre class=\"brush:java\">public class Bar {\r\n\r\n    private FastDateFormat dateFormat;\r\n\r\n    public void init() {\r\n        dateFormat = FastDateFormat.getDateTimeInstance(FULL, FULL);\r\n    }\r\n\r\n    public String format(Date date) {\r\n        return dateFormat.format(date);\r\n    }\r\n}\r\n<\/pre>\n<p>There is something disturbing about this code. First of all there is surprisingly a lot of XML. It is still less compared to similar EJB 2.1 application (with <a href=\"https:\/\/github.com\/nurkiewicz\/spring-di\/tree\/spring-1.2.6\">minor changes<\/a> this code runs on Spring 1.2.6 dating back to 2006), but it just feels wrong. The public setters are even more disturbing \u2013 why are we forced to expose the ability to override object dependencies at any time and by anyone? By the way I never really understood why Spring does not allow injecting dependencies directly to private fields when  tag is used since it is possible with&#8230;<\/p>\n<p><strong> Annotations<\/strong> [<a href=\"https:\/\/github.com\/nurkiewicz\/spring-di\/tree\/annotations\">full source<\/a>]<\/p>\n<p>Java 5 and Spring 2.5 brought support for annotation-driven dependency injection:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\"brush:xml\">&lt;context:annotation-config\/&gt;\r\n\r\n&lt;!-- or even: --&gt;\r\n\r\n&lt;context:component-scan base-package=\"com.blogspot.nurkiewicz\"\/&gt;\r\n<\/pre>\n<p>Take the first line and you no longer have to define &lt;property&gt; tags in your XML, only &lt;bean&gt;s. The framework will pick up standard @Resource annotations. Replace it with the second line and you don&#8217;t even have to specify beans in your XML at all:<\/p>\n<pre class=\"brush:java\">@Service\r\npublic class Foo {\r\n\r\n    @Resource\r\n    private Bar bar;\r\n\r\n    @Resource\r\n    private JdbcOperations jdbcOperations;\r\n\r\n    public String serverTime() {\r\n        return bar.format(\r\n                jdbcOperations.queryForObject(\"SELECT now()\", Date.class)\r\n        );\r\n    }\r\n}\r\n<\/pre>\n<pre class=\"brush:java\">@Service\r\npublic class Bar {\r\n\r\n    private FastDateFormat dateFormat;\r\n\r\n    @PostConstruct\r\n    public void init() {\r\n        dateFormat = FastDateFormat.getDateTimeInstance(FULL, FULL);\r\n    }\r\n\r\n    public String format(Date date) {\r\n        return dateFormat.format(date);\r\n    }\r\n}\r\n<\/pre>\n<p>Of course you are not impressed! <i>Nihil novi<\/i>. Also we still have to live with XML because we have no control over 3rd party classes (like data source and <a href=\"http:\/\/static.springsource.org\/spring\/docs\/3.0.x\/javadoc-api\/org\/springframework\/jdbc\/core\/JdbcTemplate.html\">JdbcTemplate<\/a>), hence we can&#8217;t annotate them. But Spring 3.0 introduced:<\/p>\n<p><strong>@Configuration<\/strong> [<a href=\"https:\/\/github.com\/nurkiewicz\/spring-di\/tree\/at-configuration\">full source<\/a>]<\/p>\n<p>I&#8217;ve been already exploring the <a href=\"http:\/\/nurkiewicz.blogspot.com\/2011\/01\/spring-framework-without-xml-at-all.html\">@Configuration\/@Bean<\/a> support, so this time please focus on how we start the application context. Do you see any reference to the XML file? The applicationContext.xml descriptor is gone completely:<\/p>\n<pre class=\"brush:java\">@ComponentScan(\"com.blogspot.nurkiewicz\")\r\npublic class Bootstrap {\r\n\r\n    private static final Logger log = LoggerFactory.getLogger(Bootstrap.class);\r\n\r\n    @Bean\r\n    public DataSource dataSource() {\r\n        final BasicDataSource dataSource = new BasicDataSource();\r\n        dataSource.setDriverClassName(\"org.h2.Driver\");\r\n        dataSource.setUrl(\"jdbc:h2:mem:\");\r\n        dataSource.setUsername(\"sa\");\r\n        return dataSource;\r\n    }\r\n\r\n    @Bean\r\n    public JdbcTemplate jdbcTemplate() {\r\n        return new JdbcTemplate(dataSource());\r\n    }\r\n\r\n    public static void main(String[] args) {\r\n        final AbstractApplicationContext applicationContext = new AnnotationConfigApplicationContext(Bootstrap.class);\r\n        final Foo foo = applicationContext.getBean(Foo.class);\r\n\r\n        log.info(foo.serverTime());\r\n\r\n        applicationContext.close();\r\n    }\r\n}\r\n<\/pre>\n<p>As you can see Spring came quite a long road from XML-heavy to XML-free framework. But the most exciting part is that you can you use whichever style you prefer or even mix them. You can take legacy Spring application and start using annotations or switch to XML for god knows what reasons here or there.<\/p>\n<p>One technique I haven&#8217;t mentioned is constructor injection. It has some great benefits (see <a href=\"http:\/\/tech.finn.no\/2011\/05\/13\/dependency-injection-with-constructors\/\">Dependency Injection with constructors?<\/a>), like ability to mark dependencies as final and forbidding to create uninitialized objects:<\/p>\n<pre class=\"brush:java\">@Service\r\npublic class Foo {\r\n\r\n    private final Bar bar;\r\n\r\n    private final JdbcOperations jdbcOperations;\r\n\r\n    @Autowired\r\n    public Foo(Bar bar, JdbcOperations jdbcOperations) {\r\n        this.bar = bar;\r\n        this.jdbcOperations = jdbcOperations;\r\n    }\r\n\r\n    \/\/...\r\n\r\n}\r\n<\/pre>\n<p>I would love constructor injection, however once again I feel a bit disappointed. Each and every object dependency requires (a) constructor parameter, (b) final field and (c) assignment operation in constructor. We end up with ten lines of code that don&#8217;t do anything yet. This chatty code overcomes all the advantages. Of course no object should have more than (put your number here) dependencies \u2013 and thanks to constructor injection you immediately <strong>see<\/strong> that the object has too many \u2013 but still I find this code introducing too much ceremony.<\/p>\n<p><strong>Spring constructor injection with Scala<\/strong> [<a href=\"https:\/\/github.com\/nurkiewicz\/spring-di\/tree\/scala\">full source<\/a>]<\/p>\n<p>One feature of Scala fits perfectly into Spring framework: each argument of any Scala object by default creates final field named the same as this argument. What does this mean in our case? Look at Foo class translated to Scala:<\/p>\n<pre class=\"brush:java\">@Service\r\nclass Foo @Autowired() (bar: Bar, jdbcOperations: JdbcOperations) {\r\n\r\n    def serverTime() = bar.format(jdbcOperations.queryForObject(\"SELECT now()\", classOf[Date]))\r\n\r\n}\r\n<\/pre>\n<p>Seriously? But&#8230; how? Before we dive into advantages of Scala here, look at the equivalent Java code as generated by Java decompiler:<\/p>\n<pre class=\"brush:java\">@Service\r\npublic class Foo implements ScalaObject\r\n{\r\n    private final Bar bar;\r\n    private final JdbcOperations jdbcOperations;\r\n\r\n    @Autowired\r\n    public Foo(Bar bar, JdbcOperations jdbcOperations)\r\n    {\r\n        this.bar = bar;\r\n        this.jdbcOperations = jdbcOperations;\r\n    }\r\n\r\n    public String serverTime()\r\n    {\r\n        return this.bar.format(this.jdbcOperations.queryForObject(\"SELECT now()\", Date.class));\r\n    }\r\n\r\n}\r\n<\/pre>\n<p>Almost exactly the same code as we would have written in Java. With all the advantages: dependencies are final making our services truly immutable and stateless; dependencies are private and not exposed to the outside world; literally no extra code to manage dependencies: just add constructor argument, Scala will take care of the rest.<\/p>\n<p>To wrap things up \u2013 you have a wide range of possibilities. From XML, through Java code to Scala. The last approach is actually very tempting as it saves you from all the boilerplate and allows you to focus on business functionality. The <a href=\"https:\/\/github.com\/nurkiewicz\/spring-di\">full source code<\/a> is available under my GitHub repository, each step is tagged so you can compare and choose whichever approach you like the most.<\/p>\n<p><strong>References :&nbsp;<\/strong><a href=\"http:\/\/nurkiewicz.blogspot.com\/2011\/09\/evolution-of-spring-dependency.html\">The evolution of Spring dependency injection techniques<\/a>&nbsp;from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG<\/a> partner&nbsp;<i><a href=\"http:\/\/www.blogger.com\/profile\/05938011050162061962\">Tomek Nurkiewicz<\/a><\/i>&nbsp;at <a href=\"http:\/\/nurkiewicz.blogspot.com\/\">NoBlogDefFound<\/a><\/p>\n<p>Happy Coding! Do not forget to share!<\/p>\n<p><strong>Related Articles:<\/strong><\/p>\n<ul style=\"text-align: left\">\n<li><a href=\"http:\/\/www.javacodegeeks.com\/?tag=java-best-practices\">Java Best Practices Series<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/01\/10-tips-proper-application-logging.html\">10 Tips for Proper Application Logging<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2010\/12\/things-every-programmer-should-know.html\">Things Every Programmer Should Know<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/02\/9-tips-on-surviving-wild-west.html\">9 Tips on Surviving the Wild West Development Process<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/01\/laws-of-software-design.html\">Laws of Software Design<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/02\/java-forkjoin-parallel-programming.html\">Java Fork\/Join for Parallel Programming<\/a><\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Looking back at the history of Spring framework you will find out that the number of ways you can implement dependency injection is growing in every release. If you&#8217;ve been working with this framework for more than a month you&#8217;ll probably find nothing interesting in this retrospective article. Nothing hopefully except the last example in &hellip;<\/p>\n","protected":false},"author":13,"featured_media":240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[124,30],"class_list":["post-586","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-dependency-injection","tag-spring"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>The evolution of Spring dependency injection techniques - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Looking back at the history of Spring framework you will find out that the number of ways you can implement dependency injection is growing in every\" \/>\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\/2011\/09\/evolution-of-spring-dependency.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The evolution of Spring dependency injection techniques - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Looking back at the history of Spring framework you will find out that the number of ways you can implement dependency injection is growing in every\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2011\/09\/evolution-of-spring-dependency.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=\"2011-09-03T10:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-21T20:20:58+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=\"Tomasz Nurkiewicz\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/tnurkiewicz\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tomasz Nurkiewicz\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/evolution-of-spring-dependency.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/evolution-of-spring-dependency.html\"},\"author\":{\"name\":\"Tomasz Nurkiewicz\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/fb1be85725c10e8361e641fa851e79e1\"},\"headline\":\"The evolution of Spring dependency injection techniques\",\"datePublished\":\"2011-09-03T10:00:00+00:00\",\"dateModified\":\"2012-10-21T20:20:58+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/evolution-of-spring-dependency.html\"},\"wordCount\":757,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/evolution-of-spring-dependency.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"keywords\":[\"Dependency Injection\",\"Spring\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/evolution-of-spring-dependency.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/evolution-of-spring-dependency.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/evolution-of-spring-dependency.html\",\"name\":\"The evolution of Spring dependency injection techniques - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/evolution-of-spring-dependency.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/evolution-of-spring-dependency.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"datePublished\":\"2011-09-03T10:00:00+00:00\",\"dateModified\":\"2012-10-21T20:20:58+00:00\",\"description\":\"Looking back at the history of Spring framework you will find out that the number of ways you can implement dependency injection is growing in every\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/evolution-of-spring-dependency.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/evolution-of-spring-dependency.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/evolution-of-spring-dependency.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\\\/2011\\\/09\\\/evolution-of-spring-dependency.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\":\"The evolution of Spring dependency injection techniques\"}]},{\"@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\\\/fb1be85725c10e8361e641fa851e79e1\",\"name\":\"Tomasz Nurkiewicz\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f2a8f9f1060fc7c1161c42f8ba901e0e79fb767dec39ec34b2d3b95cab9dc728?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f2a8f9f1060fc7c1161c42f8ba901e0e79fb767dec39ec34b2d3b95cab9dc728?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f2a8f9f1060fc7c1161c42f8ba901e0e79fb767dec39ec34b2d3b95cab9dc728?s=96&d=mm&r=g\",\"caption\":\"Tomasz Nurkiewicz\"},\"description\":\"Java EE developer, Scala enthusiast. Enjoying data analysis and visualization. Strongly believes in the power of testing and automation.\",\"sameAs\":[\"http:\\\/\\\/nurkiewicz.blogspot.com\\\/\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/tnurkiewicz\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/tomasz-nurkiewicz\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"The evolution of Spring dependency injection techniques - Java Code Geeks","description":"Looking back at the history of Spring framework you will find out that the number of ways you can implement dependency injection is growing in every","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\/2011\/09\/evolution-of-spring-dependency.html","og_locale":"en_US","og_type":"article","og_title":"The evolution of Spring dependency injection techniques - Java Code Geeks","og_description":"Looking back at the history of Spring framework you will find out that the number of ways you can implement dependency injection is growing in every","og_url":"https:\/\/www.javacodegeeks.com\/2011\/09\/evolution-of-spring-dependency.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2011-09-03T10:00:00+00:00","article_modified_time":"2012-10-21T20:20:58+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":"Tomasz Nurkiewicz","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/tnurkiewicz","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Tomasz Nurkiewicz","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/evolution-of-spring-dependency.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/evolution-of-spring-dependency.html"},"author":{"name":"Tomasz Nurkiewicz","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/fb1be85725c10e8361e641fa851e79e1"},"headline":"The evolution of Spring dependency injection techniques","datePublished":"2011-09-03T10:00:00+00:00","dateModified":"2012-10-21T20:20:58+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/evolution-of-spring-dependency.html"},"wordCount":757,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/evolution-of-spring-dependency.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","keywords":["Dependency Injection","Spring"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2011\/09\/evolution-of-spring-dependency.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/evolution-of-spring-dependency.html","url":"https:\/\/www.javacodegeeks.com\/2011\/09\/evolution-of-spring-dependency.html","name":"The evolution of Spring dependency injection techniques - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/evolution-of-spring-dependency.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/evolution-of-spring-dependency.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","datePublished":"2011-09-03T10:00:00+00:00","dateModified":"2012-10-21T20:20:58+00:00","description":"Looking back at the history of Spring framework you will find out that the number of ways you can implement dependency injection is growing in every","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/evolution-of-spring-dependency.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2011\/09\/evolution-of-spring-dependency.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/evolution-of-spring-dependency.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\/2011\/09\/evolution-of-spring-dependency.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":"The evolution of Spring dependency injection techniques"}]},{"@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\/fb1be85725c10e8361e641fa851e79e1","name":"Tomasz Nurkiewicz","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f2a8f9f1060fc7c1161c42f8ba901e0e79fb767dec39ec34b2d3b95cab9dc728?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f2a8f9f1060fc7c1161c42f8ba901e0e79fb767dec39ec34b2d3b95cab9dc728?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f2a8f9f1060fc7c1161c42f8ba901e0e79fb767dec39ec34b2d3b95cab9dc728?s=96&d=mm&r=g","caption":"Tomasz Nurkiewicz"},"description":"Java EE developer, Scala enthusiast. Enjoying data analysis and visualization. Strongly believes in the power of testing and automation.","sameAs":["http:\/\/nurkiewicz.blogspot.com\/","https:\/\/x.com\/https:\/\/twitter.com\/tnurkiewicz"],"url":"https:\/\/www.javacodegeeks.com\/author\/tomasz-nurkiewicz"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/586","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\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=586"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/586\/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=586"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=586"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}