Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you are using Spring 3, you can take advantage of the Spring Expression Language. Let's say you have two applications app1.war and app2.war and they require a properties file named config.properties. The applications will be deployed with context paths /app1 and /app2.</p> <p>Create two directories app1 and app2 in a common directory, eg. C:\myConfig\app1 and C:\myConfig\app2.</p> <p>Put config.properties inside app1 and another config.properties inside app2.</p> <p>Then create a file ${CATALINA_HOME}/conf/[enginename]/[hostname]/context.xml.default with the contents:</p> <p>context.xml.default:</p> <pre><code>&lt;Context&gt; &lt;Parameter name="myConfigDirectory" value="C:/myConfig" override="false"/&gt; &lt;/Context&gt; </code></pre> <p>The parameter myConfigDirectory will be available to all the applications on the host. It is better to create this parameter in context.xml.default rather than in server.xml, because the file can be changed later without restarting tomcat.</p> <p>In the applicationContext.xml inside war you can access config.properties using the SpEL expression: "#{contextParameters.myConfigDirectory + servletContext.contextPath}/config.properties", so for example you can write:</p> <p>applicationContext.xml:</p> <pre><code>&lt;bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt; &lt;property name="location" value="file:#{contextParameters.myConfigDirectory + servletContext.contextPath}/config.properties" /&gt; &lt;/bean&gt; </code></pre> <p>The expression will get expanded to C:/myConfig/app1 for application with contextPath /app1, and C:/myConfig/app2 for application with contextPath /app2. This will make the applications access the config.properties file based on their contextPath.</p>
    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. 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