Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h1>UPDATE</h1> <p>We later upgraded to Spring 3.0.X and we were able to take advantage of the spring expression language. Our approach simplified from three beans to the following snippet:</p> <pre><code>&lt;bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt; &lt;property name="locations"&gt; &lt;list&gt; &lt;value&gt;classpath:defaults.properties&lt;/value&gt; &lt;value&gt;file:/a/defined/location/project.properties&lt;/value&gt; &lt;value&gt;file:${AN_ENV_CONFIGURED_DIR}/project.properties&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;property name="ignoreResourceNotFound" value="true" /&gt; &lt;property name="searchSystemEnvironment" value="true" /&gt; &lt;property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" /&gt; &lt;/bean&gt; </code></pre> <p>This allowed us to have either a development (the first defaults) statically well known location, or a deployed location configured via env variables. The configurer processes these in order (i.e. the deployed takes precedence over the defaults).</p> <h1>OLD</h1> <p>I ended up going with a non programmatic approach. I used a MethodInvoker to retrieve the environment value. I was able to then pass that into the FileSystemResource. </p> <pre><code>&lt;bean id="configPath" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean" &gt; &lt;property name="targetClass" value="java.lang.String" /&gt; &lt;property name="staticMethod" value="java.lang.System.getenv" /&gt; &lt;property name="arguments"&gt; &lt;list&gt; &lt;value&gt;NAME_OF_VARIABLE&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload