title: Optional @PropertySource location
body: <p>I'm using Spring 3.2 in a web application and I'd like to have a <code>.properties</code> file within the classpath which contains default values. The user should be able to use JNDI to define a location where another <code>.properties</code> is stored which overrides the default values.</p>
  
  <p>The following works as long as the user has set the <code>configLocation</code> as JNDI property.</p>
  
  <pre><code>@Configuration
  @PropertySource({ "classpath:default.properties", "file:${java:comp/env/configLocation}/override.properties" })
  public class AppConfig
  {
  }
  </code></pre>
  
  <p>However, the external overrides should be optional and so should the JNDI property. </p>
  
  <p>Currently I get an exception (<code>java.io.FileNotFoundException: comp\env\configLocation\app.properties (The system cannot find the path specified)</code> when the JNDI property is missing.</p>
  
  <p>How can I define optional <code>.properties</code> that are used only when the JNDI property (<code>configLocation</code>) is set? Is this even possible with <code>@PropertySource</code> or is there another solution?</p>