title: Spring applicationcontext.xml read a properties file from path existing in other classpath porperties
body: <p>i need to read properties  from a properties file whose path is indicated in other properties file.</p>
  
  <p>The first properties file have a key with the path of the other properties. This file is in my classpath. Ej:</p>
  
  <p>configpathfile.properties</p>
  
  <pre><code>&gt; configpath=pathToMyConfigFile/config.properties
  </code></pre>
  
  <p>The config.properties file can be in anywhere in the server. </p>
  
  <p>config.properties</p>
  
  <pre><code>&gt; database.driverClassName=org.postgresql.Driver
  &gt; database.url=jdbc\:postgresql\://172.20.7.177\:5432/administrados
  &gt; database.username=postgres database.password=postgres
  </code></pre>
  
  <p>I have made some attemps, but all failed:</p>
  
  <p>First attemp: </p>
  
  <p>In my applicationContext.xml</p>
  
  <pre><code>&lt;context:property-placeholder location="classpath:configpathfile.properties,file:${configpath}"/&gt;
  
  &lt;bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource"&gt;
          &lt;property name="driverClassName" value="${database.driverClassName}"/&gt;
          &lt;property name="url" value="${database.url}"/&gt;
          &lt;property name="username" value="${database.username}"/&gt;
          &lt;property name="password" value="${database.password}"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>When tomcat startup, I get the error :</p>
  
  <p>Could not load properties; nested exception is java.io.FileNotFoundException: ${configpath} (No existe el archivo o el directorio)</p>
  
  <p>Second attemp:</p>
  
  <p>In my applicationContext.xml</p>
  
  <pre><code>&lt;context:property-placeholder location="classpath:configpathfile.properties"/&gt;
  
  &lt;bean id="myProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"&gt;
          &lt;property name="ignoreResourceNotFound" value="true" /&gt;
              &lt;property name="locations" value="file:${ruta}" &gt;
  
      &lt;/bean&gt;
  
  &lt;bean class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" id="dataSource"&gt;
          &lt;property name="driverClassName" value="${database.driverClassName}"/&gt;
          &lt;property name="url" value="${database.url}"/&gt;
          &lt;property name="username" value="${database.username}"/&gt;
          &lt;property name="password" value="${database.password}"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>but it fails, because it can't find the properties.</p>
  
  <p>How is the best approach for this task?
  Thanks.</p>