PropertyPlaceholderConfigurer - 它可以加载给定目录路径中的所有文件吗?

时间:2014-09-24 20:17:43

标签: spring core

Spring PropertyPlaceholderConfigurer是否占用目录位置并加载所有属性文件,而不必显式指定文件名。

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
        <property name="location" value="<path to all properties files>" />     
</bean>

还有其他方法可以达到这个目的吗?

1 个答案:

答案 0 :(得分:0)

你可以做这样的事情

<context:property-placeholder location="classpath:file1.properties,classpath*:project-common.properties,classpath*:project-${spring.profiles.active}.properties"/>

在我的情况下,它是一个遗留系统,因此属性文件没有一些标准名称,但您肯定可以使用通配符来引用属性文件。

<context:property-placeholder location="classpath:*.properties"/>