通过spring加载属性文件不在我的类路径中

时间:2016-09-09 07:43:52

标签: java spring

有没有办法通过Spring加载属性文件,而不是在我的类路径中?我试过这样的事情

<bean id="variableProperties"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
    <list>
        <value>classpath:network.properties</value>
        <value>/conf/app.properties</value>
    </list>
    </property>

此处未加载/conf/app.properties并抛出

Could not load properties; nested exception is java.io.FileNotFoundException: classpath resource [conf/app.properties] cannot be opened because it does not exist

1 个答案:

答案 0 :(得分:0)

尝试file:/conf/app.properties,但我认为你必须把绝对路径放在其中

相关问题