我正在制作具有文件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