Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>For all of our environments, configuration data lives on the target machines in the form of properties files. We use <a href="http://static.springsource.org/spring/docs/3.0.x/api/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.html" rel="nofollow noreferrer">PropertyPlaceholderconfigurer</a> from SpringFramework to bind these properties to our apps to keep things portable accross environments. </p> <p>For example, as long as I know that /etc/myapp/database.properties will be present on whatever machine my app will be running on, then in my spring configuration, I just need something like so:</p> <pre><code> &lt;bean id="myPropertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt; &lt;property name="locations"&gt; &lt;list&gt; &lt;value&gt;/etc/myapp/database.properties&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; &lt;bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource"&gt; &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt; &lt;property name="url" value="jdbc:mysql://${db.host}:3306/${db.name}" /&gt; &lt;property name="username" value="${db.user}" /&gt; &lt;property name="password" value="${db.pass}" /&gt; &lt;/bean&gt; </code></pre> <p>There are a bunch of options for that Spring class about where properties files can live. You can even make them substitutions and pass them in as environment variables:</p> <pre><code> &lt;bean id="myPropertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt; &lt;property name="searchSystemEnvironment" value="true" /&gt; &lt;property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" /&gt; &lt;property name="locations"&gt; &lt;list&gt; &lt;value&gt;${database.configuration.file.url}&lt;/value&gt; &lt;/list&gt; &lt;/property&gt; &lt;/bean&gt; </code></pre> <p>And in bash_profile (or whatever): export JAVA_OPTS="-Ddatabase.configuration.file.url=file:///etc/myapp/database.properties"</p> <p>Or just the same -D option passed in when you call "java" depending on what you are doing.</p> <p>FWIW, we maintain our properties files separately as RPMs.</p>
    singulars
    1. This table or related slice is empty.
    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. 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.
    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