一、现象
运行maven工程报错,PropertiesUtil不能读取配置文件
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.ailk.nbs.portal.autotest.util.BmsSocket.newUser(BmsSocket.java:14)
at com.ailk.nbs.portal.autotest.util.BmsSocket.main(BmsSocket.java:30)
Caused by: java.lang.NullPointerException
at java.util.Properties$LineReader.readLine(Unknown Source)
at java.util.Properties.load(Unknown Source)
at com.ailk.nbs.portal.autotest.util.PropertiesUtil.<init>(PropertiesUtil.java:17)
at com.ailk.nbs.portal.autotest.util.PropertiesUtil.<clinit>(PropertiesUtil.java:10)
... 2 more
二、原因
编译的目标文件夹下只有class文件,没有资源文件
三、解决办法
选中resource ,点击Build path-> inclusion and exclusion patterns,发现Exclusion patterns:*.*把文件都排除了,所以输出失败。把*.* remove掉即可解决问题