我加载在弹簧的context.xml属性文件,我在 $给 外部属性文件位置的占位符{} spring.profiles.active的.properties这是在类路径中,并使用该位置作为placholder在spring-context.xml。我弹簧的context.xml是:无法在spring-context.xml中加载属性文件。属性文件的路径给出的dev.properties
<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。
我希望我解释得很好。请帮忙!
在此先感谢!
嗨@ЮрийПлевако我需要的ArrayList豆的reference.I修改我的问题,并张贴了我完整的弹簧context.xml中。 – Rosh
所以当你创建你的ArrayList bean时,你需要实例化PropertyPlaceHolderConfigurer,因为你在你的ArrayList bean配置中使用了占位符,而你没有它。可能的方法是在处理资源时通过构建系统解析一些占位符 –
是的。我知道但我无法找到实现它的方法。如果你能提出建议,这将会有所帮助。谢谢 – Rosh