title: Spring - how to use PropertyPlaceholderConfigurer to dynamically load files
body: <p>i have the next properties files with Spring Framework</p>
  
  <p>config.properties<br>
  with content</p>
  
  <pre><code>environment=devel //posible values: devel, testing, prod
  </code></pre>
  
  <p>and with the previous environment property, choose some of the following files to load dynamically</p>
  
  <pre><code>config-service1-devel.properties
  config-service1-testing.properties
  config-service1-prod.properties
  config-serviceN-devel.properties
  config-serviceN-testing.properties
  config-serviceN-prod.properties
  </code></pre>
  
  <p>and then, with spring i want load the properties, i'm solve to load the first properties file but i dont understand how to use expression language to complete the values of the dependent properties.</p>
  
  <pre><code>&lt;bean id="MainApplicationProperties"
      class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
      &lt;property name="location"
          value="file://#{systemProperties['jboss.server.home.dir']}/conf/services.properties" /&gt;
  
      &lt;property name="placeholderPrefix" value="$mainProperty{" /&gt;
      &lt;property name="placeholderSuffix" value="}" /&gt;
  &lt;/bean&gt;
  &lt;bean id="SecondApplicationProperties"
      class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
      depends-on="MainApplicationProperties"&gt;
  
      &lt;property name="locations"&gt;
          &lt;list&gt;
              &lt;value&gt;file://#{systemProperties['jboss.server.home.dir']}/conf/serviceOne/service1-$mainProperty{environment}.properties&lt;/value&gt;
              &lt;value&gt;file://#{systemProperties['jboss.server.home.dir']}/conf/serviceTwo/service2-$mainProperty{environment}.properties&lt;/value&gt;
              &lt;value&gt;file://#{systemProperties['jboss.server.home.dir']}/conf/serviceN/serviceN-$mainProperty{environment}.properties&lt;/value&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  
  &lt;/bean&gt;
  </code></pre>
  
  <p>the error output is the next, </p>
  
  <pre><code>java.io.FileNotFoundException: /..../conf/serviceOne/service1-$mainProperty{environment}.properties (No such file or directory)
  </code></pre>
  
  <p>my opinion is, the value has not replaced</p>
  
  <p>helpme, thanks</p>