2010-04-07 74 views
2

有沒有辦法在文件系統上(而不是在類路徑上)引用相對於Spring上下文文件本身的屬性文件?在Spring中指定相對於上下文XML的位置

我想要做的就是下面的:

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
    <property name="locations"> 
     <list> 
      <!-- I want the below to be relative to this context XML file. --> 
      <value>app.properties</value> 
     </list> 
    </property> 
</bean> 

我想象像${contextpath},我可以預先考慮到上述的「app.properties」,但找不到任何幫助。

謝謝。

+0

你爲什麼不把路徑上的屬性文件,並與您的Spring應用程序得到它。這是一樣的權利?您可以動態更改您的屬性文件內容值。 – 2010-05-22 23:21:32

回答

0

您可以通過classpath:前綴在classpath引用屬性:

<value>classpath:app.properties</value> 
+0

謝謝Bohzo。你是否知道指定一個相對於上下文文件而不是類路徑的「文件路徑」? – 2010-04-08 01:51:05

相關問題