【发布时间】:2017-01-24 08:24:28
【问题描述】:
我在 spring-context.xml 中加载属性文件,我正在给 外部属性文件位置 ${spring.profiles.active}.properties 位于类路径中,并在 spring-context.xml 中将该位置用作占位符。我的 spring-context.xml 是:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreResourceNotFound" value="true" />
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="searchSystemEnvironment" value="true" />
<property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
<property name="locations" ref="propertyConfigurerFiles" />
</bean>
<bean id="propertyConfigurerFiles" class="java.util.ArrayList">
<constructor-arg>
<list>
<value>/WEB-INF/properties/common.properties</value>
<!--In Developemnet Enviroenment it will be dev.properties-->
<value>/WEB-INF/properties/${spring.profiles.active}.properties</value>
<!--External Property File Location as a Placeholder-->
<value>${app.config.batch.location}</value>
</list>
</constructor-arg>
</bean>
而我的 dev.properties 是:
app.config.batch.location=E:/project/properties/config.properties
我的问题是 ${app.config.batch.location} 占位符不是 在 spring-context.xml 中解决并尝试加载文件 ${app.config.batch.location} 代替 E:/project/properties/config.properties.
我希望我能很好地解释这个问题。请帮忙!
提前致谢!!!
【问题讨论】:
标签: spring properties property-placeholder