14
我需要添加一些屬性文件到我的應用程序。我已將此文件添加到controller
目錄,但無法加載它們(在類路徑中沒有?) - InputStream
爲空。在哪裏可以訪問這個文件?去哪裏投入資源?
public class Application extends Controller {
static {
try {
Properties p = new Properties();
InputStream in = Application.class.getClassLoader().getResourceAsStream("accounts.properties");
if(in != null) {
p.load(in);
in.close();
} else {
error("null inputstream");
}
} catch (Exception e) {
e.printStackTrace();
}
}
// Actions below
// ...
}
使用較新版本的'sbt',您可以編寫:'resourceDirectories in Compile + = baseDirectory.value /「爲MyResources「' –