context:property-placeholder不适用于多个文件

Fre*_*ser 17 java spring spring-mvc

我有2个属性文件.我已经提到了这两个文件context:property-placeholder......

<context:property-placeholder location="conf/ConfServer.conf,conf/LicenseSettings.properties" />
Run Code Online (Sandbox Code Playgroud)

我也尝试过这个

<context:property-placeholder location="conf/ConfServer.conf,conf/LicenseSettings.properties" />

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <list>
            <value>conf/LicenseSettings.properties</value>
        </list>
    </property>
   <property name="ignoreUnresolvablePlaceholders" value="true"/>
</bean>
Run Code Online (Sandbox Code Playgroud)

我尝试的上述两种方法都不起作用.
任何人都可以发现错误并帮助我解决这个问题吗?
我已经提到了这一点,但它对我没有用.

Kev*_*sox 43

您可以context:property-placeholder在配置文件中指定多个标记.您还可以使用该order属性指定首先加载的内容.

<context:property-placeholder location="conf/ConfServer.conf" order="1" ignore-unresolvable="true" />
<context:property-placeholder location="conf/LicenseSettings.properties" order="2" ignore-unresolvable="true" />
Run Code Online (Sandbox Code Playgroud)

  • 使用Spring 4.1.5,我只设法成功使用单个上下文:property-placeholder标记,但"location"属性接受多个以逗号分隔的位置.参见例如http://stackoverflow.com/a/3407752/218139 (2认同)