Spark submit 找不到配置文件的異常信息
java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Properties.java:434)
at java.util.Properties.load0(Properties.java:353)
at java.util.Properties.load(Properties.java:341)
at org.example.PropertyUtil.loadConf(PropertyUtil.java:37)
at org.example.PropertyUtil.<clinit>(PropertyUtil.java:17)
對應的代碼
public static Properties loadConf(String file) {
Properties pro = new Properties();
try {
InputStream in = pro.getClass().getResourceAsStream(file);
pro.load(in);
in.close();
} catch (Exception e) {
e.printStackTrace();
}
return pro;
}
已測試ok的方法
private static Properties loadConf(String file) {
Properties pro = new Properties();
try {
pro.load(new FileInputStream(file));
} catch (Exception e) {
e.printStackTrace();
}
return pro;
}
配置文件對應的目錄:src/main/resources/xxxx.properties