How a JAR file can read an external properties file

后端 未结 7 1084
星月不相逢
星月不相逢 2020-12-24 10:01

We have a connection pooling component (JAR file) for one of our application. As of now the application connection details are bundled with-in the JAR file (in .proper

7条回答
  •  离开以前
    2020-12-24 10:21

    This is my solution. First looking for app.properties in startup folder, if does not exists try to load from your JAR package:

    File external = new File("app.properties");
    if (external.exists())
        properties.load(new FileInputStream(external));
    else 
        properties.load(Main.class.getClassLoader().getResourceAsStream("app.properties"));
    

提交回复
热议问题