我想从外部文件夹加载所有属性文件Spring
。我成功加载了一个文件,但添加通配符到混音似乎不起作用。从弹簧加载多个外部属性文件
此作品(负载test.properties):
<bean id="propertiesLocation"
class="org.springframework.web.context.support.ServletContextParameterFactoryBean">
<property name="initParamName"><value>file://EXTERNAL_DIRECTORY/test.properties</value></property>
</bean>
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" ref="propertiesLocation"></property>
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="order" value="0"/>
</bean>
这不(负载的* .properties):
<bean id="propertiesLocation"
class="org.springframework.web.context.support.ServletContextParameterFactoryBean">
<property name="initParamName"><value>file://EXTERNAL_DIRECTORY/*.properties</value></property>
</bean>
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" ref="propertiesLocation"></property>
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="order" value="0"/>
</bean>
错误:
Caused by: java.io.FileNotFoundException: /EXTERNAL_DIRECTORY/*.properties (No es un directorio)
我如何使弹簧加载文件夹中的所有外部属性文件?
编辑:我用的第一个bean(ServletContextParameterFactoryBean),因为在这个项目我检索来自web.xml
文件的路径。我忘了这个,只是在bean中粘贴了路径,这是不正确的,但与问题无关。
你真的有一个root/EXTERNAL_DIRECTORY吗? – 2016-03-04 12:18:33
结帐这个答案http://stackoverflow.com/questions/8924912/multiple-properties-files-in-spring-3-0 – jozzy
我没有'/ EXTERNAL_DIRECTORY'文件夹,它只是一个例子。 –