Tôi cần thêm một số tệp thuộc tính vào ứng dụng của mình. Tôi đã thêm tập tin này vào thư mục controller
, nhưng không thể tải chúng (không có trong classpath?) - InputStream
là null. Nơi để đặt tập tin này để có thể được truy cập?Nơi đặt tài nguyên?
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
// ...
}
Với phiên bản mới hơn của 'sbt', bạn sẽ viết:' resourceDirectories in Compile + = baseDirectory.value/" myresources "' –