2013-01-11 30 views
1

我正在嘗試將PropertyPlaceholderConfigurer與外部屬性文件(不屬於WAR文件的一部分)一起使用。找不到PropertyPlaceholderConfigurer文件

我配置了豆如下:

<property name="location" value="${jboss.server.data.dir}/my-dir/common.properties"/> 

當WAR文件被部署,我得到的錯誤消息:

..... 無法加載性能;嵌套異常是java.io.FileNotFoundException:無法打開ServletContext資源[/C:/dir/jboss-as-7.1.1.Test/standalone/data/my-dir/common.properties]

任何方式我可以將屬性文件放在WAR文件之外?

回答

4

是的你可以,但使用值classpath:common.properties。只要確保它在類路徑中。

<property name="location" value="classpath:common.properties"/> 

您還可以使用該文件:如果它不在類路徑中,可以使用該文件:

<property name="location" value="file:${jboss.server.data.dir}/my-dir/common.properties"/> 
+0

它可以使用 「文件...」 謝謝。 – user1971304