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
本文详细探讨了Sparksubmit在启动时遇到的配置文件加载异常问题,深入分析了NullPointerException的产生原因,并提供了两种不同的解决方案,包括从类路径和文件系统加载配置文件的方法。

2258

被折叠的 条评论
为什么被折叠?



