title: Unable to find way to load multiple properties files into corresponding independent java objects using Spring framework
body: <p>Request you read full question before commenting out anything. It happened in past. Couple of guys commented without going through complete question and description.
  I did google and searched for questions on stackoverflow but none of them answers my issue. I know how to load multiple properties file using Environment and without using Environment object.</p>
  
  <p><strong>Environment</strong>
  Spring based application
  Using Java config way to to load environment.</p>
  
  <p><strong>Requirement:</strong> </p>
  
  <blockquote>
    <p>Want to load multiple properties files into different corresponding java
    objects in the application.</p>
  </blockquote>
  
  <p>Files are like application.properties, message_codes.properties, client_db_schema_medic.properties, client_db_schema_sme.properties etc. Each property file has data related to specific operation which is dynamic. 
  Example: client_db_schema_medic.properties has complete schema detail of a particular user group. Based on the schema/queries defined on the properties file, dynamic schema generation happens.</p>
  
  <p>This can be achieved only by loading different objects having data of different properties files.</p>
  
  <p>Example: Properties object client_db_schema_medic has data of the client_db_schema_medic.properties file, Properties object client_db_schema_sme has data of the client_db_schema_sme.properties file and so on.</p>
  
  <p>I can not mix data of multiple properties files into single object because of dynamic operation performed based on data on specific properties file.</p>
  
  <p>All the files are known and to be prepared by developer. Let me explain more. Database designer is going to share the schema of various client side databases for various user groups of the application like SME, Medic etc. These schema are going to shared in .properties files like client_db_schema_medic.properties, client_db_schema_sme.properties etc. Later server side developer is going to dynamically load these properties files and execute each of the sql statement(properties files have queries to generate schema for various user group.) and generate the schema dynamically.</p>
  
  <p>In current implementation, all the properties files are getting loaded into environment object, later i distinguish the operation by special checks on the code. This is not good practice and design.</p>
  
  <p>But now i want to automate complete process and perform dynamic operation based on different loaded object.
  Below is the current partial code snippet</p>
  
  <pre><code>@Configuration
  @PropertySource(Common.CLASSPATH_APPLICATION_PROPERTIES)
  public class JpaConfig {
  
      @Autowired
      private Environment env;
  
      JpaConfig() {
          super();
      }
  
      /**
       * @return Map&lt;String, Object&gt; of JPA properties.
       * @Purpose Method loads the Hibernate configuration information like
       *          dialect, show SQL etc. from application.properties file and
       *          stores into Map.
       */
      @Bean
      public Map&lt;String, Object&gt; jpaProperties() {
          Map&lt;String, Object&gt; props = new HashMap&lt;String, Object&gt;();
          props.put(ConfigConstants.HIBERNATE_DIALECT,
                  this.env.getRequiredProperty(ConfigConstants.HIBERNATE_DIALECT));
          props.put(
                  ConfigConstants.HIBERNATE_CAHCE_PROVIDER_CLASS,
                  this.env.getRequiredProperty(ConfigConstants.HIBERNATE_CAHCE_PROVIDER_CLASS));
          props.put(ConfigConstants.HIBERNATE_HBM2DDL_AUTO, this.env
                  .getRequiredProperty(ConfigConstants.HIBERNATE_HBM2DDL_AUTO));
          props.put(ConfigConstants.HIBERNATE_SHOW_SQL, this.env
                  .getRequiredProperty(ConfigConstants.HIBERNATE_SHOW_SQL));
          props.put(ConfigConstants.HIBERNATE_FORMAT_SQL, this.env
                  .getRequiredProperty(ConfigConstants.HIBERNATE_FORMAT_SQL));
          JpaConfig.LOGGER
                  .info("Loaded JPA properties from config file. Properties are:"
                          + props.toString());
  
          return props;
      }
  }
  </code></pre>
  
  <p>Couple of links have already gone through:</p>
  
  <p><a href="http://www.baeldung.com/2012/02/06/properties-with-spring/" rel="nofollow noreferrer">http://www.baeldung.com/2012/02/06/properties-with-spring/</a></p>
  
  <p><a href="http://fahdshariff.blogspot.in/2012/09/spring-3-javaconfig-loading-properties.html" rel="nofollow noreferrer">http://fahdshariff.blogspot.in/2012/09/spring-3-javaconfig-loading-properties.html</a></p>
  
  <p><a href="https://stackoverflow.com/questions/22784577/how-to-import-optional-properties-file-for-production-in-spring-config?rq=1">How to import optional properties file for production in Spring config?</a></p>
  
  <p><a href="http://www.jayway.com/2014/02/16/spring-propertysource/" rel="nofollow noreferrer">http://www.jayway.com/2014/02/16/spring-propertysource/</a></p>
  
  <p>Note: I can write custom util class to load the properties files into independent java objects. But i do not want to develop custom rather want to use Spring provided way to load properties files.</p>
  
  <p>Thanks in advance.</p>