{"id":1615,"date":"2012-08-29T13:00:00","date_gmt":"2012-08-29T13:00:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/spring-profiles-and-java-configuration.html"},"modified":"2012-10-22T06:17:54","modified_gmt":"2012-10-22T06:17:54","slug":"spring-profiles-and-java-configuration","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profiles-and-java-configuration.html","title":{"rendered":"Spring Profiles and Java Configuration"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\">My last blog                     <a href=\"http:\/\/www.captaindebug.com\/2012\/08\/using-spring-profiles-in-xml-config.html\" target=\"new\">introduced Spring 3.1\u2019s profiles<\/a> and explained both the business case for using them and demonstrated their use with Spring XML configuration files. It seems, however, that a good number of developers prefer using Spring\u2019s Java based application configuration and so Spring have designed a way of using profiles with their existing                     <tt>@Configuration<\/tt> annotation.                    <a href=\"http:\/\/www.blogger.com\/blogger.g?blogID=8574118689743302986\" name=\"more\"><\/a><\/p>\n<p>I\u2019m going to demonstrate profiles and the                     <tt>@Configuration<\/tt> annotation using the                     <tt>Person<\/tt> class from my previous blog. This is a simple bean class whose properties vary depending upon which profile is active.                                                                                      <\/p>\n<pre class=\"brush:java\">public class Person { \r\n \r\n  private final String firstName; \r\n  private final String lastName; \r\n  private final int age; \r\n \r\n  public Person(String firstName, String lastName, int age) { \r\n    this.firstName = firstName; \r\n    this.lastName = lastName; \r\n    this.age = age; \r\n  } \r\n \r\n  public String getFirstName() { \r\n    return firstName; \r\n  } \r\n \r\n  public String getLastName() { \r\n    return lastName; \r\n  } \r\n \r\n  public int getAge() { \r\n    return age; \r\n  } \r\n}<\/pre>\n<p>Remember that the Guys at Spring recommend that Spring profiles should only be used when you need to load different types or sets of classes and that for setting properties you should continue using the                     <tt>PropertyPlaceholderConfigurer<\/tt>. The reason I\u2019m breaking the rules is that I want to try to write the simplest code possible to demonstrate profiles and Java configuration.<\/p>\n<p>At the heart of using Spring profiles with Java configuration is Spring\u2019s new                     <tt>@Profile<\/tt> annotation. The                     <tt>@Profile<\/tt> annotation is used attach a profile name to an                     <tt>@Configuration<\/tt> annotation. It takes a single parameter that can be used in two ways. Firstly to attach a single profile to an                     <tt>@Configuration<\/tt> annotation:                                                                                     <\/p>\n<pre class=\"brush:java\">@Profile(\"test1\")<\/pre>\n<p>and secondly, to attach multiple profiles:                                                                                     <\/p>\n<pre class=\"brush:java\">@Profile({ \"test1\", \"test2\" })<\/pre>\n<p>Again, I\u2019m going to define two profiles \u201ctest1\u201d and \u201ctest2\u201d and associate each with a configuration file. Firstly \u201ctest1\u201d:                                                                                     <\/p>\n<pre class=\"brush:java\">@Configuration \r\n@Profile(\"test1\") \r\npublic class Test1ProfileConfig { \r\n \r\n  @Bean \r\n  public Person employee() { \r\n \r\n    return new Person(\"John\", \"Smith\", 55); \r\n  } \r\n}<\/pre>\n<p>&#8230;and then \u201ctest2\u201d:                                                                                     <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:java\">@Configuration \r\n@Profile(\"test2\") \r\npublic class Test2ProfileConfig { \r\n \r\n  @Bean \r\n  public Person employee() { \r\n \r\n    return new Person(\"Fred\", \"Williams\", 22); \r\n  } \r\n}<\/pre>\n<p>In the code above, you can see that I&#8217;m creating a                     <tt>Person<\/tt> bean with an effective id of                     <tt>employee<\/tt> (this is from the method name) that returns differing property values in each profile.<\/p>\n<p>Also note that the                     <tt>@Profile<\/tt> is marked as:                                                                <\/p>\n<pre class=\"brush:java\">@Target(value=TYPE)\r\n<\/pre>\n<p>&#8230;which means that is can only be placed next to the                     <tt>@Configuration<\/tt> annotation.<\/p>\n<p>Having attached an                     <tt>@Profile<\/tt> to an                     <tt>@Configuration<\/tt>, the next thing to do is to activate your selected                     <tt>@Profile<\/tt>. This uses exactly the same principles and techniques that I described in my                     <a href=\"http:\/\/www.captaindebug.com\/2012\/08\/using-spring-profiles-in-xml-config.html\" target=\"new\">last blog<\/a> and again, to my mind, the most useful activation technique is to use the &#8220;spring.profiles.active&#8221; system property.                                                                                     <\/p>\n<pre class=\"brush:java\">  @Test \r\n  public void testProfileActiveUsingSystemProperties() { \r\n \r\n    System.setProperty(\"spring.profiles.active\", \"test1\"); \r\n    ApplicationContext ctx = new ClassPathXmlApplicationContext(\"profiles-config.xml\"); \r\n \r\n    Person person = ctx.getBean(\"employee\", Person.class); \r\n    String firstName = person.getFirstName(); \r\n    assertEquals(\"John\", firstName); \r\n  }<\/pre>\n<p>Obviously, you wouldn\u2019t want to hard code things as I\u2019ve done above and best practice usually means keeping the system properties configuration separate from your application. This gives you the option of using either a simple command line argument such as:                                                                <\/p>\n<pre class=\"brush:java\">-Dspring.profiles.active=\"test1\"\r\n<\/pre>\n<p>&#8230;or by adding                                                                 <\/p>\n<pre class=\"brush:java\"># Setting a property value\r\nspring.profiles.active=test1\r\n<\/pre>\n<p>to Tomcat\u2019s                     <tt>catalina.properties<\/tt><\/p>\n<p>So, that\u2019s all there is to it: you create your Spring profiles by annotating an                     <tt>@Configuration<\/tt> with an                     <tt>@Profile<\/tt> annotation and then switching on the profile you want to use by setting the                     <tt>spring.profiles.active<\/tt> system property to your                     <tt>profile<\/tt>\u2019s name.<\/p>\n<p>As usual, the Guys at Spring don\u2019t just confine you to using system properties to activate profiles, you can do things programatically. For example, the following code creates an                     <tt>AnnotationConfigApplicationContext<\/tt> and then uses an                     <tt>Environment<\/tt> object to activate the \u201ctest1\u201d profile, before registering our                     <tt>@Configuration<\/tt> classes.                                                                                     <\/p>\n<pre class=\"brush:java\">  @Test \r\n  public void testAnnotationConfigApplicationContextThatWorks() { \r\n \r\n    \/\/ Can register a list of config classes \r\n    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); \r\n    ctx.getEnvironment().setActiveProfiles(\"test1\"); \r\n    ctx.register(Test1ProfileConfig.class, Test2ProfileConfig.class); \r\n    ctx.refresh(); \r\n \r\n    Person person = ctx.getBean(\"employee\", Person.class); \r\n    String firstName = person.getFirstName(); \r\n    assertEquals(\"John\", firstName); \r\n  }<\/pre>\n<p>This is all fine and good, but beware, you need to call                     <tt>AnnotationConfigApplicationContext<\/tt>\u2019s methods in the right order. For example, if you register your                     <tt>@Configuration<\/tt> classes before you specify your profile, then you\u2019ll get an                     <tt>IllegalStateException<\/tt>.                                                                                     <\/p>\n<pre class=\"brush:java\">  @Test(expected = IllegalStateException.class) \r\n  public void testAnnotationConfigApplicationContextThatFails() { \r\n \r\n    \/\/ Can register a list of config classes \r\n    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext( \r\n        Test1ProfileConfig.class, Test2ProfileConfig.class); \r\n    ctx.getEnvironment().setActiveProfiles(\"test1\"); \r\n    ctx.refresh(); \r\n \r\n    Person person = ctx.getBean(\"employee\", Person.class); \r\n    String firstName = person.getFirstName(); \r\n    assertEquals(\"John\", firstName); \r\n  }<\/pre>\n<p>Before closing today\u2019s blog, the code below demonstrates the ability to attach multiple                     <tt>@Profiles<\/tt> to an                     <tt>@Configuration<\/tt> annotation.                                                                                     <\/p>\n<pre class=\"brush:java\">@Configuration \r\n@Profile({ \"test1\", \"test2\" }) \r\npublic class MulitpleProfileConfig { \r\n \r\n  @Bean \r\n  public Person tourDeFranceWinner() { \r\n \r\n    return new Person(\"Bradley\", \"Wiggins\", 32); \r\n  } \r\n}<\/pre>\n<pre class=\"brush:java\">  @Test \r\n  public void testMulipleAssignedProfilesUsingSystemProperties() { \r\n \r\n    System.setProperty(\"spring.profiles.active\", \"test1\"); \r\n    ApplicationContext ctx = new ClassPathXmlApplicationContext(\"profiles-config.xml\"); \r\n \r\n    Person person = ctx.getBean(\"tourDeFranceWinner\", Person.class); \r\n    String firstName = person.getFirstName(); \r\n    assertEquals(\"Bradley\", firstName); \r\n \r\n    System.setProperty(\"spring.profiles.active\", \"test2\"); \r\n    ctx = new ClassPathXmlApplicationContext(\"profiles-config.xml\"); \r\n \r\n    person = ctx.getBean(\"tourDeFranceWinner\", Person.class); \r\n    firstName = person.getFirstName(); \r\n    assertEquals(\"Bradley\", firstName); \r\n  }<\/pre>\n<p>&nbsp;In the code above, 2012 Tour De France winner Bradley Wiggins appears in both the \u201ctest1\u201d and \u201ctest2\u201d profiles.      <strong><i>&nbsp;<\/i><\/strong><\/p>\n<p><strong><i>Reference: <\/i><\/strong><a href=\"http:\/\/www.captaindebug.com\/2012\/08\/using-spring-profiles-and-java.html\">Spring, Enterprise Java <\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a> Roger Hughes at the <a href=\"http:\/\/www.captaindebug.com\/\">Captain Debug&#8217;s Blog <\/a> blog.  <\/div>\n","protected":false},"excerpt":{"rendered":"<p>My last blog introduced Spring 3.1\u2019s profiles and explained both the business case for using them and demonstrated their use with Spring XML configuration files. It seems, however, that a good number of developers prefer using Spring\u2019s Java based application configuration and so Spring have designed a way of using profiles with their existing @Configuration &hellip;<\/p>\n","protected":false},"author":65,"featured_media":240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[30],"class_list":["post-1615","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 Profiles and Java Configuration - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"My last blog introduced Spring 3.1\u2019s profiles and explained both the business case for using them and demonstrated their use with Spring XML configuration\" \/>\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\/08\/spring-profiles-and-java-configuration.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring Profiles and Java Configuration - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"My last blog introduced Spring 3.1\u2019s profiles and explained both the business case for using them and demonstrated their use with Spring XML configuration\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profiles-and-java-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=\"2012-08-29T13:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-22T06:17:54+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=\"Roger Hughes\" \/>\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=\"Roger Hughes\" \/>\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\\\/08\\\/spring-profiles-and-java-configuration.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/08\\\/spring-profiles-and-java-configuration.html\"},\"author\":{\"name\":\"Roger Hughes\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/c9feacaf8e783104a69621cd65bf1f07\"},\"headline\":\"Spring Profiles and Java Configuration\",\"datePublished\":\"2012-08-29T13:00:00+00:00\",\"dateModified\":\"2012-10-22T06:17:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/08\\\/spring-profiles-and-java-configuration.html\"},\"wordCount\":579,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/08\\\/spring-profiles-and-java-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\\\/2012\\\/08\\\/spring-profiles-and-java-configuration.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/08\\\/spring-profiles-and-java-configuration.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/08\\\/spring-profiles-and-java-configuration.html\",\"name\":\"Spring Profiles and Java Configuration - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/08\\\/spring-profiles-and-java-configuration.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/08\\\/spring-profiles-and-java-configuration.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"datePublished\":\"2012-08-29T13:00:00+00:00\",\"dateModified\":\"2012-10-22T06:17:54+00:00\",\"description\":\"My last blog introduced Spring 3.1\u2019s profiles and explained both the business case for using them and demonstrated their use with Spring XML configuration\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/08\\\/spring-profiles-and-java-configuration.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/08\\\/spring-profiles-and-java-configuration.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/08\\\/spring-profiles-and-java-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\\\/2012\\\/08\\\/spring-profiles-and-java-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\":\"Spring Profiles and Java Configuration\"}]},{\"@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\\\/c9feacaf8e783104a69621cd65bf1f07\",\"name\":\"Roger Hughes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/db9d1e5362dbc3f8007b383b852473b59fb8c5282a6066a13ab1cef761a9d5d6?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/db9d1e5362dbc3f8007b383b852473b59fb8c5282a6066a13ab1cef761a9d5d6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/db9d1e5362dbc3f8007b383b852473b59fb8c5282a6066a13ab1cef761a9d5d6?s=96&d=mm&r=g\",\"caption\":\"Roger Hughes\"},\"sameAs\":[\"http:\\\/\\\/www.captaindebug.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Roger-Hughes\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring Profiles and Java Configuration - Java Code Geeks","description":"My last blog introduced Spring 3.1\u2019s profiles and explained both the business case for using them and demonstrated their use with Spring XML configuration","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\/08\/spring-profiles-and-java-configuration.html","og_locale":"en_US","og_type":"article","og_title":"Spring Profiles and Java Configuration - Java Code Geeks","og_description":"My last blog introduced Spring 3.1\u2019s profiles and explained both the business case for using them and demonstrated their use with Spring XML configuration","og_url":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profiles-and-java-configuration.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2012-08-29T13:00:00+00:00","article_modified_time":"2012-10-22T06:17:54+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":"Roger Hughes","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Roger Hughes","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profiles-and-java-configuration.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profiles-and-java-configuration.html"},"author":{"name":"Roger Hughes","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/c9feacaf8e783104a69621cd65bf1f07"},"headline":"Spring Profiles and Java Configuration","datePublished":"2012-08-29T13:00:00+00:00","dateModified":"2012-10-22T06:17:54+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profiles-and-java-configuration.html"},"wordCount":579,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profiles-and-java-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\/2012\/08\/spring-profiles-and-java-configuration.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profiles-and-java-configuration.html","url":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profiles-and-java-configuration.html","name":"Spring Profiles and Java Configuration - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profiles-and-java-configuration.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profiles-and-java-configuration.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","datePublished":"2012-08-29T13:00:00+00:00","dateModified":"2012-10-22T06:17:54+00:00","description":"My last blog introduced Spring 3.1\u2019s profiles and explained both the business case for using them and demonstrated their use with Spring XML configuration","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profiles-and-java-configuration.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profiles-and-java-configuration.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profiles-and-java-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\/2012\/08\/spring-profiles-and-java-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":"Spring Profiles and Java Configuration"}]},{"@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\/c9feacaf8e783104a69621cd65bf1f07","name":"Roger Hughes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/db9d1e5362dbc3f8007b383b852473b59fb8c5282a6066a13ab1cef761a9d5d6?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/db9d1e5362dbc3f8007b383b852473b59fb8c5282a6066a13ab1cef761a9d5d6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/db9d1e5362dbc3f8007b383b852473b59fb8c5282a6066a13ab1cef761a9d5d6?s=96&d=mm&r=g","caption":"Roger Hughes"},"sameAs":["http:\/\/www.captaindebug.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/Roger-Hughes"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/1615","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\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=1615"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/1615\/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=1615"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=1615"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=1615"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}