我使用Apache公共配置庫來提取我的配置列表,當我的網站開始。在哪裏把Apache的公共配置文件
但它總是拋出錯誤找不到配置源。
我應該在哪裏放置我的配置文件?
這裏的web.xml:
<servlet>
<servlet-name>Quartz</servlet-name>
<servlet-class>me.myclass.Init</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
,並在我的代碼:
public void init()
{
XMLConfiguration xmlConfig;
try {
xmlConfig = new XMLConfiguration("/WEB-INF/scheduler.xml");
System.out.println(xmlConfig.getString("master"));
} catch (org.apache.commons.configuration.ConfigurationException ex) {
System.out.println(ex);
}
}
是否有一個位置可以放置Servlet將使用的配置數據,以便它可以專用於運行它的環境,但不在Servlet的WAR文件中? (例如,不在web.xml或隨Servlet類一起提供的/ WEB-INF /文件夾中)。我有一個需要在多個環境中運行的Servlet(例如,連接到「dev」,「test」和「production」的不同服務器,但是WAR包本身不應該從環境變爲環境。) – iX3 2013-03-19 19:18:58