我正在製作具有文件default.properties中的默認屬性的庫。如何替換庫中的默認屬性
private static String defPropertyPath = "/database.properties";
我想問這個文件是否可以被使用我的庫的程序替換。因此,程序將定義具有相同名稱default.properties的屬性,以取代庫中的屬性。我在我使用庫的程序中創建了default.properties,但庫仍然從它們的包中加載屬性。
編輯: 我讀的性能通過輸入流文件:
InputStream ins = DbProperties.class.getResourceAsStream(defPropertyPath);
if (ins == null) {
logger.error("Can't find properties:" + pathToProperties);
return;
}
編輯:文件結構:
DbLibrary.jar
/
/database.properties
/src
MyApplication.jar
/
/database.properties
/src
/lib/DbLibrary.jar
我的應用程序中使用DbLibrary.jar並希望迫使這個庫使用來自MyApplication的database.properties而不是來自DbLibrary。
請發佈您的代碼訪問上述文件。你如何閱讀它? – 2012-01-03 15:29:55
您的自定義default.properties必須在類路徑中的庫之前_這種方式您可以確保它會在庫之前被讀取 – fge 2012-01-03 15:30:35