I had a similar error with reading properties file. After a bit of research I added this piece of code to pom:
<build>
<resources>
<resource>
<directory>src/main/resources/</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
And this is how I read from the file:
/**
* loads default config from internal source
*
* @return true/false upon success/failure of loading config
*/
private static boolean loadDefault() {
if (null != properties) return false;
try (InputStream resourceStream = Config.class.getClassLoader().getResourceAsStream("config.properties")) {
properties = new Properties();
properties.load(resourceStream);
return true;
} catch (NullPointerException | IOException exception) {
String detail = ExceptionHandler.format(exception, "Could not load default config");
log.error(detail);
properties = null;
return false;
}
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…