1
maven Webアプリケーションを使用しています。 プロパティファイルを配置したプロジェクトの構造は次のとおりです。
Mavenプロパティファイルが見つかりません
次は、私がこのファイルを読むために使用しています私のコードです:
public static Properties loadProducerProperty() throws FileException {
Properties myProperties = new Properties();
try {
String resourceName = "newproperties.properties"; // could also be a constant
ClassLoader loader = Thread.currentThread().getContextClassLoader();
try (InputStream resourceStream = loader.getResourceAsStream(resourceName)) {
myProperties.load(resourceStream);
}
} catch (FileNotFoundException e) {
throw new FileException();
} catch (IOException e) {
throw new FileException();
}
return myProperties;
}
しかし、私は次のリンクを経て他のものを試してみましたFileNotFound
例外
を取得しています同じエラーが発生しています:
Cannot load properties file from resources directory
私はここで間違っています。
は