{"id":542,"date":"2011-09-22T12:45:00","date_gmt":"2011-09-22T12:45:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/swapping-out-spring-bean-configuration-at-runtime.html"},"modified":"2012-10-21T20:12:55","modified_gmt":"2012-10-21T20:12:55","slug":"swapping-out-spring-bean-configuration","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2011\/09\/swapping-out-spring-bean-configuration.html","title":{"rendered":"Swapping out Spring Bean Configuration at Runtime"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\">Most Java developers these days deal with Spring on a regular basis and there are lots of us out there that have become familiar with its abilities as well as its limitations.<\/p>\n<p>I recently came across a problem that I hadn\u2019t hit before: introducing the ability to rewire a bean\u2019s internals based on configuration introduced at runtime. This is valuable for simple configuration changes or perhaps swapping out something like a <strong>Strategy<\/strong> or <strong>Factory<\/strong> class, rather than rebuilding of a complex part of the application context.<\/p>\n<p>I was able to find some notes about how to do this, but I thought that some might find my notes and code samples useful, especially since I can confirm this technique works on versions of Spring back to 1.2.6. Unfortunately, not all of us are lucky enough to be on the latest and greatest of every library.<\/p>\n<p><strong><span class=\"Apple-style-span\" style=\"font-size: large\">Scope of the Problem<\/span><\/strong><\/p>\n<p>The approach I\u2019m going to outline is meant primarily to target changes to a single bean, though this code could easily be extended to change multiple beans. It could be invoked through JMX or some other UI exposed to administrators.<\/p>\n<p>One thing it does not cover is rewiring a singleton all across an application \u2013 this could conceivably be done via some reflection and inspection of the current application context, but is likely to be unsafe in most applications unless they have some way of temporarily shutting down or blocking all processing for a period while the changes are made all over the application.<\/p>\n<p><strong><span class=\"Apple-style-span\" style=\"font-size: large\">The Code<\/span><\/strong><\/p>\n<p>Here\u2019s the sample code. It will take a list of Strings which contains bean definitions, and wire them into a new temporary Spring context. You\u2019ll see a parent context can be provided, which is useful in case your new bean definitions need to refer to beans already configured in the application.<\/p>\n<pre class=\"brush:java\">public static &lt;T&gt; Map&lt;String, T&gt; extractBeans(Class&lt;T&gt; beanType,\r\n   List&lt;String&gt; contextXmls, ApplicationContext parentContext) throws Exception {\r\n\r\n   List&lt;String&gt; paths = new ArrayList&lt;String&gt;();\r\n   try {\r\n      for (String xml : contextXmls) {\r\n         File file = File.createTempFile(\"spring\", \"xml\");\r\n         \/\/ ... write the file using a utility method\r\n         FileUtils.writeStringToFile(file, xml, \"UTF-8\");\r\n         paths.add(file.getAbsolutePath());\r\n      }\r\n\r\n      String[] pathArray = paths.toArray(new String[0]);\r\n      return buildContextAndGetBeans(beanType, pathArray, parentContext);\r\n\r\n   } finally {\r\n      \/\/ ... clean up temp files immediately if desired\r\n   }\r\n}\r\n\r\nprivate static &lt;T&gt; Map&lt;String, T&gt; buildContextAndGetBeans(Class&lt;T&gt; beanType,\r\n               String[] paths, ApplicationContext parentContext) throws Exception {\r\n\r\n   FileSystemXmlApplicationContext context =\r\n      new FileSystemXmlApplicationContext(paths, false, parentContext) {\r\n         @Override  \/\/ suppress refresh events bubbling to parent context\r\n         public void publishEvent(ApplicationEvent event) { }\r\n      };\r\n\r\n   try {\r\n      \/\/ avoid classloader errors in some environments\r\n      context.setClassLoader(beanType.getClassLoader());\r\n      context.refresh(); \/\/ parse and load context\r\n      Map&lt;String, T&gt; beanMap = context.getBeansOfType(beanType);\r\n\r\n      return beanMap;\r\n   } finally {\r\n      try {\r\n         context.close();\r\n      } catch (Exception e) {\r\n         \/\/ ... log this\r\n      }\r\n   }\r\n} \r\n<\/pre>\n<p>If you look at <strong>buildContextAndGetBeans()<\/strong>, you\u2019ll see it does the bulk of the work by building up a Spring context with the supplied XML bean definition files. It then returns a map of the constructed beans of the type requested.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><strong>Note:<\/strong> Since the temporary Spring context is destroyed, ensure your beans do not have lifecycle methods that cause them to be put into an invalid state when stopped or destroyed.<\/p>\n<p>Here\u2019s an example of a Spring context that might be used to rewire a component. Imagine we have an e-commerce system that does fraud checks, but various strategies for checking for fraud. We may wish to swap these from our service class without having to stop and reconfigure the application, since we lose business when we do so. Perhaps we are finding a specific abuse of the system that would be better dealt with by changing the strategy used to locate fraudulent orders.<\/p>\n<p>Here\u2019s a sample XML definition that could be used to rewire our <strong>FraudService<\/strong>.<\/p>\n<pre class=\"brush:xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\r\n&lt;!DOCTYPE beans PUBLIC \"-\/\/SPRING\/\/DTD BEAN\/\/EN\" \"http:\/\/www.springframework.org\/dtd\/spring-beans.dtd\"&gt;\r\n&lt;beans&gt;\r\n   &lt;bean id=\"fraudStrategy\" class=\"com.example.SomeFraudStategory\"&gt;\r\n      &lt;!-- example of a bean defined in the parent application context that we can reference --&gt;\r\n      &lt;property name=\"fraudRuleFactory\" ref=\"fraudRuleFactory\"\/&gt;\r\n   &lt;\/bean&gt;\r\n&lt;\/beans&gt;\r\n<\/pre>\n<p>And here is the code you could use to rewire your bean with a reference to the defined <strong>fraudStrategy<\/strong>, assuming you have it in a utility class called <strong>SpringUtils<\/strong>:<\/p>\n<pre class=\"brush:java\">public class FraudService implements ApplicationContextAware {\r\n\r\n   private ApplicationContext context;\r\n   \/\/ volatile for thread safety (in Java 1.5 and up only)\r\n   private volatile FraudStrategy fraudStrategy;\r\n\r\n   @Override \/\/ get a handle on the the parent context\r\n   public void setApplicationContext(ApplicationContext context) {\r\n      this.context = context;\r\n   }\r\n\r\n   public void swapFraudStategy(String xmlDefinition) throws Exception {\r\n      List&lt;Sting&gt; definitions = Arrays.asList(xmlDefinition);\r\n      Map&lt;String, FraudStrategy&gt; beans =\r\n         SpringUtils.extractBeans(FraudStrategy.class, definitions, context);\r\n      if (beans.size() != 1) {\r\n         throw new RuntimeException(\"Invalid number of beans: \" + beans .size());\r\n      }\r\n      this.fraudStrategy = beans.values().iterator().next();\r\n   }\r\n\r\n}\r\n<\/pre>\n<p>And there you have it! This example could be extended a fair bit to meet your needs, but I think it shows the fundamentals of how to create a Spring context on the fly, and use its beans to reconfigure your application without any need for downtime.<\/p>\n<p><strong><i>Reference: <\/i><\/strong><a href=\"http:\/\/www.carfey.com\/blog\/swapping-out-spring-bean-configuration-at-runtime\/\">Swapping out Spring Bean Configuration at Runtime<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a>s at the <a href=\"http:\/\/www.carfey.com\/blog\/\">Carfey Software blog<\/a>.<\/p>\n<div style=\"margin: 0px\"><strong><i>Related Articles :<\/i><\/strong><\/div>\n<ul>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/01\/spring-configuration-zero-xml.html\">Spring configuration with zero XML<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/09\/evolution-of-spring-dependency.html\">The evolution of Spring dependency injection techniques<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/04\/spring-mvc3-hibernate-crud-sample.html\">Spring MVC3 Hibernate CRUD Sample Application<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/01\/aspect-oriented-programming-spring-aop.html\">Aspect Oriented Programming with Spring AOP<\/a><\/li>\n<li><a href=\"http:\/\/www.javacodegeeks.com\/2011\/02\/spring-mvc-development-tutorial.html\">Spring MVC Development &#8211; Quick Tutorial<\/a><\/li>\n<\/ul>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Most Java developers these days deal with Spring on a regular basis and there are lots of us out there that have become familiar with its abilities as well as its limitations. I recently came across a problem that I hadn\u2019t hit before: introducing the ability to rewire a bean\u2019s internals based on configuration introduced &hellip;<\/p>\n","protected":false},"author":59,"featured_media":240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[30],"class_list":["post-542","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>Swapping out Spring Bean Configuration at Runtime - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Most Java developers these days deal with Spring on a regular basis and there are lots of us out there that have become familiar with its abilities as\" \/>\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\/swapping-out-spring-bean-configuration.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Swapping out Spring Bean Configuration at Runtime - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Most Java developers these days deal with Spring on a regular basis and there are lots of us out there that have become familiar with its abilities as\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2011\/09\/swapping-out-spring-bean-configuration.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-22T12:45:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-21T20:12:55+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=\"Craig Flichel\" \/>\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=\"Craig Flichel\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 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\\\/swapping-out-spring-bean-configuration.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/swapping-out-spring-bean-configuration.html\"},\"author\":{\"name\":\"Craig Flichel\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/c1bcd58320330b548e07d846510f9460\"},\"headline\":\"Swapping out Spring Bean Configuration at Runtime\",\"datePublished\":\"2011-09-22T12:45:00+00:00\",\"dateModified\":\"2012-10-21T20:12:55+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/swapping-out-spring-bean-configuration.html\"},\"wordCount\":609,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/swapping-out-spring-bean-configuration.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\\\/2011\\\/09\\\/swapping-out-spring-bean-configuration.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/swapping-out-spring-bean-configuration.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/swapping-out-spring-bean-configuration.html\",\"name\":\"Swapping out Spring Bean Configuration at Runtime - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/swapping-out-spring-bean-configuration.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/swapping-out-spring-bean-configuration.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"datePublished\":\"2011-09-22T12:45:00+00:00\",\"dateModified\":\"2012-10-21T20:12:55+00:00\",\"description\":\"Most Java developers these days deal with Spring on a regular basis and there are lots of us out there that have become familiar with its abilities as\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/swapping-out-spring-bean-configuration.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/swapping-out-spring-bean-configuration.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2011\\\/09\\\/swapping-out-spring-bean-configuration.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\\\/swapping-out-spring-bean-configuration.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\":\"Swapping out Spring Bean Configuration at Runtime\"}]},{\"@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\\\/c1bcd58320330b548e07d846510f9460\",\"name\":\"Craig Flichel\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f7ada05eac86c369123683747aa5f714e262e52d4af354efe8aba14f76075dc4?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f7ada05eac86c369123683747aa5f714e262e52d4af354efe8aba14f76075dc4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f7ada05eac86c369123683747aa5f714e262e52d4af354efe8aba14f76075dc4?s=96&d=mm&r=g\",\"caption\":\"Craig Flichel\"},\"sameAs\":[\"http:\\\/\\\/www.carfey.com\\\/blog\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Craig-Flichel\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Swapping out Spring Bean Configuration at Runtime - Java Code Geeks","description":"Most Java developers these days deal with Spring on a regular basis and there are lots of us out there that have become familiar with its abilities as","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\/swapping-out-spring-bean-configuration.html","og_locale":"en_US","og_type":"article","og_title":"Swapping out Spring Bean Configuration at Runtime - Java Code Geeks","og_description":"Most Java developers these days deal with Spring on a regular basis and there are lots of us out there that have become familiar with its abilities as","og_url":"https:\/\/www.javacodegeeks.com\/2011\/09\/swapping-out-spring-bean-configuration.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2011-09-22T12:45:00+00:00","article_modified_time":"2012-10-21T20:12:55+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":"Craig Flichel","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Craig Flichel","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/swapping-out-spring-bean-configuration.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/swapping-out-spring-bean-configuration.html"},"author":{"name":"Craig Flichel","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/c1bcd58320330b548e07d846510f9460"},"headline":"Swapping out Spring Bean Configuration at Runtime","datePublished":"2011-09-22T12:45:00+00:00","dateModified":"2012-10-21T20:12:55+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/swapping-out-spring-bean-configuration.html"},"wordCount":609,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/swapping-out-spring-bean-configuration.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\/2011\/09\/swapping-out-spring-bean-configuration.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/swapping-out-spring-bean-configuration.html","url":"https:\/\/www.javacodegeeks.com\/2011\/09\/swapping-out-spring-bean-configuration.html","name":"Swapping out Spring Bean Configuration at Runtime - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/swapping-out-spring-bean-configuration.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/swapping-out-spring-bean-configuration.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","datePublished":"2011-09-22T12:45:00+00:00","dateModified":"2012-10-21T20:12:55+00:00","description":"Most Java developers these days deal with Spring on a regular basis and there are lots of us out there that have become familiar with its abilities as","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/swapping-out-spring-bean-configuration.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2011\/09\/swapping-out-spring-bean-configuration.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2011\/09\/swapping-out-spring-bean-configuration.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\/swapping-out-spring-bean-configuration.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":"Swapping out Spring Bean Configuration at Runtime"}]},{"@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\/c1bcd58320330b548e07d846510f9460","name":"Craig Flichel","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f7ada05eac86c369123683747aa5f714e262e52d4af354efe8aba14f76075dc4?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f7ada05eac86c369123683747aa5f714e262e52d4af354efe8aba14f76075dc4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f7ada05eac86c369123683747aa5f714e262e52d4af354efe8aba14f76075dc4?s=96&d=mm&r=g","caption":"Craig Flichel"},"sameAs":["http:\/\/www.carfey.com\/blog\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/Craig-Flichel"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/542","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\/59"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=542"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/542\/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=542"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=542"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=542"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}