【发布时间】:2012-03-30 23:22:57
【问题描述】:
我有一个这样的 PropertyPlaceholderConfigurer:
<bean id="propertyPlaceholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="true"/>
<property name="locations">
<list>
<value>classpath:assuredlabor/margarita-${runningMode}.properties</value>
</list>
</property>
</bean>
我希望能够像这样在 web.xml 中指定我的运行模式:
<context-param>
<param-name>runningMode</param-name>
<param-value>production</param-value>
</context-param>
所以我把这个bean放在我上面描述的'main'属性bean之上:
<bean id="servletPropertyPlaceholderConfigurer" class="org.springframework.web.context.support.ServletContextPropertyPlaceholderConfigurer">
</bean>
但这似乎不起作用。
Spring 可以做到这一点吗?我现在使用的是 2.5 版。
我发现了这个类似的问题:
PropertyPlaceholderConfigurer with Tomcat & ContextLoaderListener
但是没有讨论 ServletContextPropertyPlaceholderConfigurer,所以我认为这是一个合理的问题。
【问题讨论】: