{"id":1714,"date":"2012-08-07T19:36:00","date_gmt":"2012-08-07T19:36:00","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/2012\/10\/spring-profile-pattern-example.html"},"modified":"2012-10-22T06:34:43","modified_gmt":"2012-10-22T06:34:43","slug":"spring-profile-pattern-example_7","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profile-pattern-example_7.html","title":{"rendered":"Spring Profile pattern example"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left\">\n<div dir=\"ltr\" style=\"text-align: left\">Recently we were introduced with the concept of                     <a href=\"http:\/\/blog.springsource.org\/2011\/02\/14\/spring-3-1-m1-introducing-profile\/\">Spring Profiles<\/a>.<\/p>\n<p>This concept is an easy configuration differentiators  for different deployment environments.<\/p>\n<p>The straight forward use case (which was presented) was to annotate the relevant classes so Spring would load the appropriate class according to the active profile.                    <\/p>\n<p>However, this approach might not always serve the common use case&#8230; often, the configuration keys would be the same and only the values will change per environment.                    <\/p>\n<p>In this post, I would like to present a pattern to support loading configuration data per environment,                     <strong>without <\/strong>the need to create\/maintain multiple classes for each profile (i.e. for each environment).                    <\/p>\n<p>Throughout the post I would take the DB connection configuration as a sample, assuming we have different DB definitions (e.g. username or connection URL) for each deployment environment.                    <\/p>\n<p>The main idea is to use                     <strong>one<\/strong> class for loading the configuration (i.e.. one class for DB connection definition) and inject into it the appropriate instance which holds the correct profile configuration data.                    <\/p>\n<p>For convenience and clarity, the process was divided into 3 phases:                    <\/p>\n<p><strong>Phase 1<\/strong>: infra preparation<br \/>\nStep 1.1  &#8211; create a properties file which contains all configuration data<br \/>\nStep 1.2  &#8211; create an annotation for each profile<br \/>\nstep 1.3  &#8211; make sure the profile is loaded during context loading                    <\/p>\n<p><strong>Phase 2<\/strong>: implementing the profile pattern<br \/>\nStep 2.1 &#8211; create a properties interface<br \/>\nStep 2.2 &#8211; create a class for each profile<br \/>\nStep 2.3 &#8211; create an abstract file which holds the entire data                    <\/p>\n<p><strong>Phase 3<\/strong>: using the pattern<br \/>\nStep 3.1 &#8211; example for using the pattern                     <\/p>\n<p><strong>Spring Profile pattern &#8211;  phase 1: infra preparation                    <\/strong><\/p>\n<p>This phase will establish the initial infra for using Spring Profile and the configuration files.                    <\/p>\n<p><strong>Step 1.1<\/strong>  &#8211; create a properties file which contains all configuration data<\/p>\n<p>Assuming you have a maven style project, create a file in src\/main\/resources\/properties for each environment, e.g:<\/p>\n<p>my_company_dev.properties<br \/>\nmy_company_test.properties<br \/>\nmy_company_production.properties                    <\/p>\n<p>example for my_company_dev.properties content:<\/p>\n<p>jdbc.url=jdbc:mysql:\/\/localhost:3306\/my_project_db<br \/>\ndb.username=dev1<br \/>\ndb.password=dev1<br \/>\nhibernate.show_sql=true                    <\/p>\n<p>example for my_company_production.properties content:                    <\/p>\n<p>jdbc.url=jdbc:mysql:\/\/10.26.26.26:3306\/my_project_db<br \/>\ndb.username=prod1<br \/>\ndb.password=fdasjkladsof8aualwnlulw344uwj9l34<br \/>\nhibernate.show_sql=false                    <\/p>\n<p><strong>Step 1.2<\/strong>  &#8211; create an annotation for each profile<\/p>\n<p>In src.main.java.com.mycompany.annotation create annotation for each Profile, e.g :                    <\/p>\n<pre class=\"brush:java\">@Target(ElementType.TYPE)\r\n@Retention(RetentionPolicy.RUNTIME)\r\n@Profile(\"DEV\")\r\npublic @interface Dev {\r\n}\r\n<\/pre>\n<pre class=\"brush:java\">@Target(ElementType.TYPE)\r\n@Retention(RetentionPolicy.RUNTIME)\r\n@Profile(\"PRODUCTION\")\r\npublic @interface Production {\r\n}\r\n<\/pre>\n<p>Create an enum for each profile:<br \/>\npublic interface MyEnums {                    <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\">\r\npublic enum Profile{\r\nDEV,\r\nTEST,\r\nPRODUCTION\r\n}\r\n<\/pre>\n<p><strong>Step 1.3<\/strong>  &#8211; make sure the profile is loaded during context loading                    <\/p>\n<ul>\n<li>Define a system variable to indicate on which environment the code is running.<br \/>\nIn Tomcat, go to ${tomcat.di}\/conf\/catalina.properties and insert a line:<br \/>\nprofile=DEV  (according to your environment)<\/li>\n<li>Define a class to set the active profile\n<pre class=\"brush:java\">public class ConfigurableApplicationContextInitializer implements\r\n  ApplicationContextInitializer&lt;configurableapplicationcontext&gt; {\r\n\r\n @Override\r\n public void initialize(ConfigurableApplicationContext applicationContext) {\r\n      \r\n  String profile = System.getProperty(\"profile\");\r\n    \r\n  if (profile==null || profile.equalsIgnoreCase(Profile.DEV.name())){\r\n   applicationContext.getEnvironment().setActiveProfiles(Profile.DEV.name());   \r\n  }else if(profile.equalsIgnoreCase(Profile.PRODUCTION.name())){\r\n   applicationContext.getEnvironment().setActiveProfiles(Profile.PRODUCTION.name()); \r\n  }else if(profile.equalsIgnoreCase(Profile.TEST.name())){\r\n   applicationContext.getEnvironment().setActiveProfiles(Profile.TEST.name()); \r\n        }\r\n }\r\n}\r\n<\/pre>\n<\/li>\n<li>Make sure the class is loaded during context loading<br \/>\nin the project web.xml, insert the following:  <\/p>\n<pre class=\"brush:xml\">                      \r\n&lt;context-param&gt;\r\n     &lt;param-name&gt;contextInitializerClasses&lt;\/param-name&gt;\r\n     &lt;param-value&gt;com.matomy.conf.ConfigurableApplicationContextInitializer&lt;\/param-value&gt;\r\n&lt;\/context-param&gt;<\/pre>\n<\/li>\n<\/ul>\n<\/div>\n<p><strong>Phase 2: implementing the profile pattern&nbsp;<\/strong><\/p>\n<p>This phase utilizes the infra we built before and implements the profile pattern.                    <\/p>\n<p><strong>Step 2.1<\/strong> &#8211; create a properties interface<br \/>\nCreate an interface for the configuration data you have.<br \/>\nIn our case, the interface will provide access to the four configuration data  items.<br \/>\nso it would look something like:                    <\/p>\n<pre class=\"brush:java\">public interface SystemStrings {\r\n\r\nString getJdbcUrl();\r\nString getDBUsername();\r\nString getDBPassword();\r\nBoolean getHibernateShowSQL();\r\n\/\/..... \r\n<\/pre>\n<p><strong>Step 2.2<\/strong> &#8211; create a class for each profile<\/p>\n<p>Example for a development profile:                     <\/p>\n<pre class=\"brush:java\">@Dev \/\/Notice the dev annotation\r\n@Component(\"systemStrings\")\r\npublic class SystemStringsDevImpl extends AbstractSystemStrings implements SystemStrings{\r\n      \r\n public SystemStringsDevImpl() throws IOException {\r\n                \/\/indication on the relevant properties file\r\n  super(\"\/properties\/my_company_dev.properties\");\r\n } \r\n}\r\n<\/pre>\n<p>Example for a production profile:                     <\/p>\n<pre class=\"brush:java\">@Prouction \/\/Notice the production annotation\r\n@Component(\"systemStrings\")\r\npublic class SystemStringsProductionImpl extends AbstractSystemStrings implements SystemStrings{\r\n      \r\n public SystemStringsProductionImpl() throws IOException {\r\n                \/\/indication on the relevant properties file\r\n  super(\"\/properties\/my_company_production.properties\");\r\n } \r\n}\r\n<\/pre>\n<p>The two classes above are where the binding between the properties file and the related environment occur.                    <\/p>\n<p>You&#8217;ve probably noticed that the classes extend an abstract class. This technique is useful so we won&#8217;t need to define each getter for each Profile, this would not be manageable in the long run, and really, there is no point of doing it.                    <\/p>\n<p>The sweet and honey lies in the next step, where the abstract class is defined.                    <\/p>\n<p><strong>Step 2.3<\/strong> &#8211; create an abstract file which holds the entire data                    <\/p>\n<pre class=\"brush:java\">public abstract class AbstractSystemStrings implements SystemStrings{\r\n\r\n \/\/Variables as in configuration properties file\r\nprivate String jdbcUrl;\r\nprivate String dBUsername;\r\nprivate String dBPassword;\r\nprivate boolean hibernateShowSQL;\r\n\r\npublic AbstractSystemStrings(String activePropertiesFile) throws IOException {\r\n  \/\/option to override project configuration from externalFile\r\n  loadConfigurationFromExternalFile();\/\/optional..\r\n                \/\/load relevant properties\r\n  loadProjectConfigurationPerEnvironment(activePropertiesFile);  \r\n }\r\n\r\nprivate void loadProjectConfigurationPerEnvironment(String activePropertiesFile) throws IOException {\r\n  Resource[] resources = new ClassPathResource[ ]  {  new ClassPathResource( activePropertiesFile ) };\r\n  Properties props = null;\r\n  props = PropertiesLoaderUtils.loadProperties(resources[0]);\r\n                jdbcUrl = props.getProperty(\"jdbc.url\");\r\n                dBUsername = props.getProperty(\"db.username\"); \r\n                dBPassword = props.getProperty(\"db.password\");\r\n                hibernateShowSQL = new Boolean(props.getProperty(\"hibernate.show_sql\"));  \r\n}\r\n\r\n\/\/here should come the interface getters....\r\n<\/pre>\n<p><strong>Phase 3: using the pattern<\/strong>                   <\/p>\n<p>As you can recall, in previous steps we defined an interface for configuration data.                    <\/p>\n<p>Now we will use                     <strong>the interface<\/strong> in a class which needs different data per environment.                    <\/p>\n<p>Please note that this example is the key differentiator from the example given in  the                     <a href=\"http:\/\/blog.springsource.org\/2011\/02\/14\/spring-3-1-m1-introducing-profile\/\">Spring blog<\/a>, since now we                     <strong>don&#8217;t need to create a class for each profile<\/strong>, since in this case we use the same method across profiles and                     <strong>only the data changes<\/strong>.                    <\/p>\n<p><strong>Step 3.1<\/strong> &#8211; example for using the pattern                    <\/p>\n<pre class=\"brush:java\">@Configuration\r\n@EnableTransactionManagement\r\n\/\/DB connection configuration class \r\n\/\/(don't tell me you're still using xml... ;-)\r\npublic class PersistenceConfig {\r\n\r\n @Autowired\r\n private SystemStrings systemStrings; \/\/Spring will wire by active profile\r\n\r\n @Bean\r\n public LocalContainerEntityManagerFactoryBean entityManagerFactoryNg(){\r\n  LocalContainerEntityManagerFactoryBean factoryBean\r\n  = new LocalContainerEntityManagerFactoryBean();\r\n  factoryBean.setDataSource( dataSource() );\r\n  factoryBean.setPersistenceUnitName(\"my_pu\");       \r\n  JpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(){\r\n   {\r\n    \/\/ JPA properties\r\n    this.setDatabase( Database.MYSQL);\r\nthis.setDatabasePlatform(\"org.hibernate.dialect.MySQLDialect\");\r\n    this.setShowSql(systemStrings.getShowSqlMngHibernate());\/\/is set per environemnt..           \r\n   \r\n   }\r\n  };       \r\n  factoryBean.setJpaVendorAdapter( vendorAdapter );\r\n  factoryBean.setJpaProperties( additionalProperties() );\r\n\r\n  return factoryBean;\r\n }\r\n\/\/...\r\n@Bean\r\n public ComboPooledDataSource dataSource(){\r\n  ComboPooledDataSource poolDataSource = new ComboPooledDataSource();\r\n  try {\r\n   poolDataSource.setDriverClass( systemStrings.getDriverClassNameMngHibernate() );\r\n  } catch (PropertyVetoException e) {\r\n   e.printStackTrace();\r\n  }       \r\n                 \/\/is set per environemnt..\r\n  poolDataSource.setJdbcUrl(systemStrings.getJdbcUrl());\r\n  poolDataSource.setUser( systemStrings.getDBUsername() );\r\n  poolDataSource.setPassword( systemStrings.getDBPassword() );\r\n  \/\/.. more properties...       \r\n  return poolDataSource;\r\n }\r\n}\r\n<\/pre>\n<p>I would appreciate comments and improvements.<br \/>\nEnjoy!    <\/p>\n<p><strong><i>Reference: <\/i><\/strong><a href=\"http:\/\/gal-levinsky.blogspot.gr\/2012\/07\/spring-profile-pattern-part-1.html\">Spring Profile pattern <\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a> Gal Levinsky at the <a href=\"http:\/\/gal-levinsky.blogspot.gr\/\">Gal Levinsky&#8217;s blog<\/a> blog.<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Recently we were introduced with the concept of Spring Profiles. This concept is an easy configuration differentiators for different deployment environments. The straight forward use case (which was presented) was to annotate the relevant classes so Spring would load the appropriate class according to the active profile. However, this approach might not always serve the &hellip;<\/p>\n","protected":false},"author":262,"featured_media":240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[30,608],"class_list":["post-1714","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-spring","tag-spring-profile"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Spring Profile pattern example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Recently we were introduced with the concept of Spring Profiles. This concept is an easy configuration differentiators for different deployment\" \/>\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-profile-pattern-example_7.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring Profile pattern example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Recently we were introduced with the concept of Spring Profiles. This concept is an easy configuration differentiators for different deployment\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profile-pattern-example_7.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-07T19:36:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2012-10-22T06:34:43+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=\"Gal Levinsky\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@http:\/\/twitter.com\/Gal_L\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Gal Levinsky\" \/>\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\\\/2012\\\/08\\\/spring-profile-pattern-example_7.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/08\\\/spring-profile-pattern-example_7.html\"},\"author\":{\"name\":\"Gal Levinsky\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/308cd2d723d5770eefb2a33ce71ba16b\"},\"headline\":\"Spring Profile pattern example\",\"datePublished\":\"2012-08-07T19:36:00+00:00\",\"dateModified\":\"2012-10-22T06:34:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/08\\\/spring-profile-pattern-example_7.html\"},\"wordCount\":744,\"commentCount\":7,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/08\\\/spring-profile-pattern-example_7.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"keywords\":[\"Spring\",\"Spring Profile\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/08\\\/spring-profile-pattern-example_7.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/08\\\/spring-profile-pattern-example_7.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/08\\\/spring-profile-pattern-example_7.html\",\"name\":\"Spring Profile pattern example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/08\\\/spring-profile-pattern-example_7.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/08\\\/spring-profile-pattern-example_7.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"datePublished\":\"2012-08-07T19:36:00+00:00\",\"dateModified\":\"2012-10-22T06:34:43+00:00\",\"description\":\"Recently we were introduced with the concept of Spring Profiles. This concept is an easy configuration differentiators for different deployment\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/08\\\/spring-profile-pattern-example_7.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/08\\\/spring-profile-pattern-example_7.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2012\\\/08\\\/spring-profile-pattern-example_7.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-profile-pattern-example_7.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 Profile pattern example\"}]},{\"@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\\\/308cd2d723d5770eefb2a33ce71ba16b\",\"name\":\"Gal Levinsky\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/58f41561b42474620463d488dfca133a87d90dab78c16e5a0ab305e6711dcc02?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/58f41561b42474620463d488dfca133a87d90dab78c16e5a0ab305e6711dcc02?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/58f41561b42474620463d488dfca133a87d90dab78c16e5a0ab305e6711dcc02?s=96&d=mm&r=g\",\"caption\":\"Gal Levinsky\"},\"description\":\"Graduated B.s.c Information System Engineering on BGU University (2004). Been working on large cloud based ERP application in SAP for 7 years and as a development group manager in affiliation company. Co-founded few startups in the domain of social web.\",\"sameAs\":[\"http:\\\/\\\/gal-levinsky.blogspot.com\",\"http:\\\/\\\/www.linkedin.com\\\/in\\\/gallevisnky\",\"https:\\\/\\\/x.com\\\/http:\\\/\\\/twitter.com\\\/Gal_L\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/Gal-Levinsky\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring Profile pattern example - Java Code Geeks","description":"Recently we were introduced with the concept of Spring Profiles. This concept is an easy configuration differentiators for different deployment","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-profile-pattern-example_7.html","og_locale":"en_US","og_type":"article","og_title":"Spring Profile pattern example - Java Code Geeks","og_description":"Recently we were introduced with the concept of Spring Profiles. This concept is an easy configuration differentiators for different deployment","og_url":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profile-pattern-example_7.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2012-08-07T19:36:00+00:00","article_modified_time":"2012-10-22T06:34:43+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":"Gal Levinsky","twitter_card":"summary_large_image","twitter_creator":"@http:\/\/twitter.com\/Gal_L","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Gal Levinsky","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profile-pattern-example_7.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profile-pattern-example_7.html"},"author":{"name":"Gal Levinsky","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/308cd2d723d5770eefb2a33ce71ba16b"},"headline":"Spring Profile pattern example","datePublished":"2012-08-07T19:36:00+00:00","dateModified":"2012-10-22T06:34:43+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profile-pattern-example_7.html"},"wordCount":744,"commentCount":7,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profile-pattern-example_7.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","keywords":["Spring","Spring Profile"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profile-pattern-example_7.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profile-pattern-example_7.html","url":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profile-pattern-example_7.html","name":"Spring Profile pattern example - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profile-pattern-example_7.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profile-pattern-example_7.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","datePublished":"2012-08-07T19:36:00+00:00","dateModified":"2012-10-22T06:34:43+00:00","description":"Recently we were introduced with the concept of Spring Profiles. This concept is an easy configuration differentiators for different deployment","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profile-pattern-example_7.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profile-pattern-example_7.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2012\/08\/spring-profile-pattern-example_7.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-profile-pattern-example_7.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 Profile pattern example"}]},{"@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\/308cd2d723d5770eefb2a33ce71ba16b","name":"Gal Levinsky","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/58f41561b42474620463d488dfca133a87d90dab78c16e5a0ab305e6711dcc02?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/58f41561b42474620463d488dfca133a87d90dab78c16e5a0ab305e6711dcc02?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/58f41561b42474620463d488dfca133a87d90dab78c16e5a0ab305e6711dcc02?s=96&d=mm&r=g","caption":"Gal Levinsky"},"description":"Graduated B.s.c Information System Engineering on BGU University (2004). Been working on large cloud based ERP application in SAP for 7 years and as a development group manager in affiliation company. Co-founded few startups in the domain of social web.","sameAs":["http:\/\/gal-levinsky.blogspot.com","http:\/\/www.linkedin.com\/in\/gallevisnky","https:\/\/x.com\/http:\/\/twitter.com\/Gal_L"],"url":"https:\/\/www.javacodegeeks.com\/author\/Gal-Levinsky"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/1714","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\/262"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=1714"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/1714\/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=1714"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=1714"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=1714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}