{"id":1405,"date":"2012-06-12T16:00:00","date_gmt":"2012-06-12T16:00:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/spring-vs-guice-the-one-critical-difference-that-matters.html"},"modified":"2012-10-22T05:38:37","modified_gmt":"2012-10-22T05:38:37","slug":"spring-vs-guice-one-critical-difference","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2012\/06\/spring-vs-guice-one-critical-difference.html","title":{"rendered":"Spring vs Guice: The one critical difference that matters"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\">\n<div style=\"text-align: justify\"><strong>Spring objects are recognized based on their names<\/strong>        <\/div>\n<div style=\"text-align: justify\">\n<\/div>\n<div style=\"text-align: justify\">It doesn\u2019t matter whether you use XML or Java config, a Spring scope is roughly like a Map&lt;String, Object&gt; structure. This means that <strong>you cannot have two objects with the same name<\/strong>. Why is this a bad thing? If you have a large application with lots of @Configuration classes or XML files, it\u2019s very easy to accidentally use the same name twice. <\/div>\n<div style=\"text-align: justify\">\n<\/div>\n<div style=\"text-align: justify\">The worst part of this is that using the same with several objects, they silently override each other until only one actually remains in the ApplicationContext. These objects can also be of different types and the declaration order is what really determines which object wins. The problem here is that if you want to make reusable modules based on Spring, you will basically be forced to use a prefix in the name or something else to ensure you won\u2019t have a name clash. <\/div>\n<div style=\"text-align: justify\">\n<\/div>\n<div style=\"text-align: justify\"><strong>Guice objects are recognized based on their classes<\/strong>        <\/div>\n<div style=\"text-align: justify\">\n<\/div>\n<div style=\"text-align: justify\">A Guice scope is basically like a Map&lt;Class&lt;?&gt;, Object&gt; structure. This means that <strong>you cannot have two objects of the same type<\/strong> without using extra metadata (e.g. qualifiers). This design choice has different pros and cons, but overall I think it\u2019s the saner one. If you create reusable modules, you mostly have to make sure that you don\u2019t export any objects of common types (e.g. String). With type-based scopes you can always create a wrapped class for common types, while with name-based scopes you would always have to use unique names based on lucky guesses. Guice also has PrivateModules so you can use Guice for all injection, but only export some of the objects in the scope.         <strong>&nbsp;<\/strong><\/div>\n<div style=\"text-align: justify\">\n<\/div>\n<div style=\"text-align: justify\"><strong>Example code<\/strong>        <\/div>\n<div style=\"text-align: justify\">\n<\/div>\n<div style=\"text-align: justify\">Here\u2019s a naive example of a Spring application that breaks runtime because of silent bean overriding.&nbsp;<\/div>\n<div style=\"text-align: justify\">\n<\/div>\n<p><strong>Main.java<\/strong>        <div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>This class instantiates the application context, registers the configuration classes and tries to get a MyBean from the context.         <\/p>\n<pre class=\"brush:java\">package springbreak;\r\n\r\nimport org.springframework.context.annotation.AnnotationConfigApplicationContext;\r\n\r\npublic class Main {\r\n  public static void main(String[] args) {\r\n    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();\r\n\r\n    ctx.register(GoodConfig.class);\r\n    ctx.register(EvilConfig.class);\r\n\r\n    ctx.refresh();\r\n    ctx.start();\r\n\r\n    System.out.println(ctx.getBean(MyBean.class).getValue());\r\n\r\n    ctx.stop();\r\n  }\r\n}<\/pre>\n<p><strong>MyBean.java<\/strong>        <\/p>\n<p>This is just an example type of bean that we expect to get from the application context.         <\/p>\n<pre class=\"brush:java\">package springbreak;\r\n\r\npublic interface MyBean {\r\n  String getValue();\r\n}<\/pre>\n<p><strong>GoodConfig.java<\/strong>        <\/p>\n<p>This is a configuration class that exports a MyBean         <\/p>\n<pre class=\"brush:java\">package springbreak;\r\n\r\nimport org.springframework.context.annotation.Bean;\r\nimport org.springframework.context.annotation.Configuration;\r\n\r\n@Configuration\r\npublic class GoodConfig {\r\n\r\n  private static class MyBeanImpl implements MyBean {\r\n    public String getValue() {\r\n      return \"I'm a bean\";\r\n    }\r\n  }\r\n\r\n  @Bean\r\n  public MyBean myBean() {\r\n    return new MyBeanImpl();\r\n  }\r\n\r\n}<\/pre>\n<p><strong>EvilConfig.java<\/strong>        <\/p>\n<p>This configuration class exports a String with the name myBean. It\u2019s not a very realistic example but shows the basic idea.         <\/p>\n<pre class=\"brush:java\">package springbreak;\r\n\r\nimport org.springframework.context.annotation.Bean;\r\nimport org.springframework.context.annotation.Configuration;\r\n\r\n@Configuration\r\npublic class EvilConfig {\r\n\r\n  @Bean\r\n  public String myBean() {\r\n    return \"I'm a string!\";\r\n  }\r\n\r\n}<\/pre>\n<div style=\"text-align: justify\"><strong>Analyzing the example<\/strong>        <\/div>\n<div style=\"text-align: justify\">\n<\/div>\n<div style=\"text-align: justify\">Can you guess what happens when you run the example? Here\u2019s the basic idea:         <\/div>\n<ol style=\"text-align: justify\">\n<li>GoodConfig exports a MyBeanImpl with the name \u201cmyBean\u201d<\/li>\n<li>EvilConfig exports a String with the name \u201cmyBean\u201d replacing the one from GoodConfig <strong>even though the types won\u2019t match<\/strong><\/li>\n<li>Main gets a NoSuchBeanDefinitionException \u201cNo unique bean of type [springbreak.MyBean] is defined\u201d <\/li>\n<\/ol>\n<ol style=\"text-align: justify\">        <\/ol>\n<div style=\"text-align: justify\">So, basically a MyBeanImpl is replaced by a String and there won\u2019t be a bean that implements MyBean. The worst part is that <i>if you reverse the @Configuration class registration order, the code will work<\/i> because then a String will be replaced by a MyBeanImpl. Now, imagine you have 20 nicely encapsulated modules with potentially conflicting names\u2026I\u2019ve banged my head against the wall several times trying to debug problems in a situation like that.         <\/div>\n<div style=\"text-align: justify\">\n<\/div>\n<div style=\"text-align: justify\">Spring (as of version 3.0.6) offers no possibility to alter the naming of @Configuration class exported beans. If you want to create safely reusable modules, you will have to use some kind of fully qualified names in the methods that export beans (e.g goodConfigMyBean, evilConfigMyBean).         <\/div>\n<div style=\"text-align: justify\">\n<\/div>\n<div style=\"text-align: justify\">I like Spring (especially non-DI-container parts), but in new projects I will refuse to use a library that is so fundamentally broken. And yes, using the same name twice is a developer error, but any library that is prone to such errors can be considered worse than an alternative that attempts to minimize them. <\/div>\n<p><strong><i>Reference: <\/i><\/strong><a href=\"http:\/\/jawsy.fi\/blog\/2011\/11\/29\/spring-vs-guice-the-one-critical-difference-that-matters\/\">Spring vs Guice: The one critical difference that matters <\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a> Joonas Javanainen  at the <a href=\"http:\/\/jawsy.fi\/blog\/\">Jawsy Solutions technical blog <\/a> blog.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Spring objects are recognized based on their names It doesn\u2019t matter whether you use XML or Java config, a Spring scope is roughly like a Map&lt;String, Object&gt; structure. This means that you cannot have two objects with the same name. Why is this a bad thing? If you have a large application with lots of &hellip;<\/p>\n","protected":false},"author":111,"featured_media":127,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[124,306,30],"class_list":["post-1405","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-dependency-injection","tag-google-guice","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 vs Guice: The one critical difference that matters - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Spring objects are recognized based on their names It doesn\u2019t matter whether you use XML or Java config, a Spring scope is roughly like a Map&lt;String,\" \/>\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\/2012\/06\/spring-vs-guice-one-critical-difference.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring vs Guice: The one critical difference that matters - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Spring objects are recognized based on their names It doesn\u2019t matter whether you use XML or Java config, a Spring scope is roughly like a Map&lt;String,\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2012\/06\/spring-vs-guice-one-critical-difference.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=\"2012-06-12T16:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-22T05:38:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/google-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=\"Joonas Javanainen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@http:\/\/twitter.com\/Gekkio\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Joonas Javanainen\" \/>\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\\\/2012\\\/06\\\/spring-vs-guice-one-critical-difference.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/spring-vs-guice-one-critical-difference.html\"},\"author\":{\"name\":\"Joonas Javanainen\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/11d056970ee9a1b348d9d320e9a2ca7f\"},\"headline\":\"Spring vs Guice: The one critical difference that matters\",\"datePublished\":\"2012-06-12T16:00:00+00:00\",\"dateModified\":\"2012-10-22T05:38:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/spring-vs-guice-one-critical-difference.html\"},\"wordCount\":655,\"commentCount\":5,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/spring-vs-guice-one-critical-difference.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/google-logo.jpg\",\"keywords\":[\"Dependency Injection\",\"Google Guice\",\"Spring\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/spring-vs-guice-one-critical-difference.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/spring-vs-guice-one-critical-difference.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/spring-vs-guice-one-critical-difference.html\",\"name\":\"Spring vs Guice: The one critical difference that matters - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/spring-vs-guice-one-critical-difference.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/spring-vs-guice-one-critical-difference.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/google-logo.jpg\",\"datePublished\":\"2012-06-12T16:00:00+00:00\",\"dateModified\":\"2012-10-22T05:38:37+00:00\",\"description\":\"Spring objects are recognized based on their names It doesn\u2019t matter whether you use XML or Java config, a Spring scope is roughly like a Map&lt;String,\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/spring-vs-guice-one-critical-difference.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/spring-vs-guice-one-critical-difference.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/spring-vs-guice-one-critical-difference.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/google-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/google-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/06\\\/spring-vs-guice-one-critical-difference.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 vs Guice: The one critical difference that matters\"}]},{\"@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\\\/11d056970ee9a1b348d9d320e9a2ca7f\",\"name\":\"Joonas Javanainen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/340875a23855972753a4340fae766e867777945e028a4809a525f2952ba16607?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/340875a23855972753a4340fae766e867777945e028a4809a525f2952ba16607?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/340875a23855972753a4340fae766e867777945e028a4809a525f2952ba16607?s=96&d=mm&r=g\",\"caption\":\"Joonas Javanainen\"},\"description\":\"Joonas is a passionate software developer from Finland. He has worked on a multitude of problem domains, and focuses professionally on functional programming and JVM-based technologies.\",\"sameAs\":[\"http:\\\/\\\/gekkio.fi\\\/blog\\\/\",\"http:\\\/\\\/fi.linkedin.com\\\/in\\\/gekkio\\\/\",\"https:\\\/\\\/x.com\\\/http:\\\/\\\/twitter.com\\\/Gekkio\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Joonas-Javanainen\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring vs Guice: The one critical difference that matters - Java Code Geeks","description":"Spring objects are recognized based on their names It doesn\u2019t matter whether you use XML or Java config, a Spring scope is roughly like a Map&lt;String,","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\/2012\/06\/spring-vs-guice-one-critical-difference.html","og_locale":"en_US","og_type":"article","og_title":"Spring vs Guice: The one critical difference that matters - Java Code Geeks","og_description":"Spring objects are recognized based on their names It doesn\u2019t matter whether you use XML or Java config, a Spring scope is roughly like a Map&lt;String,","og_url":"https:\/\/www.javacodegeeks.com\/2012\/06\/spring-vs-guice-one-critical-difference.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2012-06-12T16:00:00+00:00","article_modified_time":"2012-10-22T05:38:37+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/google-logo.jpg","type":"image\/jpeg"}],"author":"Joonas Javanainen","twitter_card":"summary_large_image","twitter_creator":"@http:\/\/twitter.com\/Gekkio","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Joonas Javanainen","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2012\/06\/spring-vs-guice-one-critical-difference.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/06\/spring-vs-guice-one-critical-difference.html"},"author":{"name":"Joonas Javanainen","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/11d056970ee9a1b348d9d320e9a2ca7f"},"headline":"Spring vs Guice: The one critical difference that matters","datePublished":"2012-06-12T16:00:00+00:00","dateModified":"2012-10-22T05:38:37+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/06\/spring-vs-guice-one-critical-difference.html"},"wordCount":655,"commentCount":5,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/06\/spring-vs-guice-one-critical-difference.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/google-logo.jpg","keywords":["Dependency Injection","Google Guice","Spring"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2012\/06\/spring-vs-guice-one-critical-difference.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2012\/06\/spring-vs-guice-one-critical-difference.html","url":"https:\/\/www.javacodegeeks.com\/2012\/06\/spring-vs-guice-one-critical-difference.html","name":"Spring vs Guice: The one critical difference that matters - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/06\/spring-vs-guice-one-critical-difference.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/06\/spring-vs-guice-one-critical-difference.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/google-logo.jpg","datePublished":"2012-06-12T16:00:00+00:00","dateModified":"2012-10-22T05:38:37+00:00","description":"Spring objects are recognized based on their names It doesn\u2019t matter whether you use XML or Java config, a Spring scope is roughly like a Map&lt;String,","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/06\/spring-vs-guice-one-critical-difference.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2012\/06\/spring-vs-guice-one-critical-difference.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2012\/06\/spring-vs-guice-one-critical-difference.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/google-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/google-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2012\/06\/spring-vs-guice-one-critical-difference.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 vs Guice: The one critical difference that matters"}]},{"@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\/11d056970ee9a1b348d9d320e9a2ca7f","name":"Joonas Javanainen","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/340875a23855972753a4340fae766e867777945e028a4809a525f2952ba16607?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/340875a23855972753a4340fae766e867777945e028a4809a525f2952ba16607?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/340875a23855972753a4340fae766e867777945e028a4809a525f2952ba16607?s=96&d=mm&r=g","caption":"Joonas Javanainen"},"description":"Joonas is a passionate software developer from Finland. He has worked on a multitude of problem domains, and focuses professionally on functional programming and JVM-based technologies.","sameAs":["http:\/\/gekkio.fi\/blog\/","http:\/\/fi.linkedin.com\/in\/gekkio\/","https:\/\/x.com\/http:\/\/twitter.com\/Gekkio"],"url":"https:\/\/www.javacodegeeks.com\/author\/Joonas-Javanainen"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/1405","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\/111"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=1405"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/1405\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/127"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=1405"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=1405"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=1405"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}