I previously used the obsolete class org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer to load the properties file from the server file system. I had the following bean defined:
<bean class="org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer"> <property name="locations" value="${config}"/> <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE"/> <property name="ignoreUnresolvablePlaceholders" value="true"/> <property name="searchContextAttributes" value="true"/> <property name="contextOverride" value="false"/> <property name="ignoreResourceNotFound" value="true"/> <property name="searchSystemEnvironment" value="false"/> </bean>
config is the argument that is passed when Tomcat starts, i.e.
-Dconfig=/path/to/application.properties
For webapp, I also have a context file:
<Context docBase="/path/to/application.war"> <Parameter name="host" value="localhost" override="false"/> <Parameter name="port" value="8080" override="false"/> </Context>
If the .properties file specified by the -Dconfig argument contains a property that contains some other bean links, then the value from the .properties file is used, otherwise the value from the XML context file b.
This allowed me to set the default set of properties deployed to WAR, and if necessary, I could specify a .properties file to override certain values.
Now I am updating to use the new property abstractions in Spring 3.1, but I cannot figure out what is the equivalent approach to this?
I have the same context file and war deployed in the same way, and now I have the following in the application:
<context:property-placeholder location="${config}" system-properties-mode="OVERRIDE" ignore-resource-not-found="true" ignore-unresolvable="true"/>
This finds and uses the properties from the properties file, BUT does not use the values ββfrom the XML context file.
How do I get my application to use context parameters when using this new placeholder?
Thanks.
spring
C0deAttack
source share