Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>several approaches:</p> <hr> <h2>1. 'Order' Property</h2> <p>in <code>src/main/resources/your-conf.xml</code></p> <pre><code>&lt;context:property-placeholder location="classpath:esb-project-config.properties" order="1"/&gt; </code></pre> <p>in <code>src/test/resources/your-test-config.xml</code></p> <pre><code>&lt;context:property-placeholder location="classpath:esb-project-config.properties" order="0"/&gt; </code></pre> <p>If you running your test with <code>src/test/resources</code> as a test classpath, the above will ensure to override <code>src/main/resources/esb-project-config.properties</code> with the <code>src/test/resources/esb-project-config.properties</code>. </p> <p>This will override the whole <code>property-placeholder</code> though, so you would have to provide all the properties needed in your application in for this test <code>property-placeholder</code>. e.g.</p> <pre><code>&lt;context:property-placeholder location="classpath:esb-project-config.properties, classpath:some-other-props-if-needed.properties" order="0"/&gt; </code></pre> <hr> <h2>2. PropertyOverrideConfigurer</h2> <pre><code> &lt;context:property-override location="classpath:esb-project-config.test.properties"/&gt; </code></pre> <p>to override certain <em>individual</em> properties. Some examples <a href="http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/htmlsingle/spring-framework-reference.html#beans-factory-overrideconfigurer" rel="noreferrer">here</a></p> <hr> <h2>3. System Variables</h2> <p>You can use a prefix to control environment specific properties, this can be done by using system variables:</p> <pre><code> &lt;context:property-placeholder location="${ENV_SYSTEM:dev}/esb-project-config.properties"/&gt; </code></pre> <p>In this case it will always look under:</p> <pre><code> &lt;context:property-placeholder location="dev/esb-project-config.properties"/&gt; </code></pre> <p><strong>by default</strong>, unless a <code>ENV_SYSTEM</code> system variable is set. If it is set to <code>qa</code>, for example, it will automatically look under:</p> <pre><code> &lt;context:property-placeholder location="qa/esb-project-config.properties"/&gt; </code></pre> <hr> <h2>4. Spring Profiles</h2> <p>Another approach is to make beans profile specific. For example:</p> <pre><code>&lt;beans profile="dev"&gt; &lt;context:property-placeholder location="esb-project-config.dev.properties"/&gt; &lt;/beans&gt; &lt;beans profile="qa"&gt; &lt;context:property-placeholder location="esb-project-config.qa.properties"/&gt; &lt;/beans&gt; </code></pre> <p>The appropriate <code>esb-project-config</code> will loaded depending on a profile set. For example this will load <code>esb-project-config.dev.properties</code>:</p> <pre><code>GenericXmlApplicationContext ctx = new GenericXmlApplicationContext(); ctx.getEnvironment().setActiveProfiles( "dev" ); ctx.load( "classpath:/org/boom/bang/config/xml/*-config.xml" ); ctx.refresh(); </code></pre> <hr> <ul> <li>NOTE: "System Variables" and "System Profiles" approaches are usually used to switch between different <em>environments</em> rather than just "dev &lt;==> test" in dev mode, but still are useful capabilities to be aware of.</li> </ul>
    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.
    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