这份代码在别人的机子上能运行,但在我的机子上却报错了,请大家帮帮忙,看看是什么问题。以下是报错信息:(主要就是properties.load()的问题,说不支持reader)
Exception sending context initialized event to listener instance of class com.fortune.hms.core.web.listener.StartupListener
java.lang.Error: Unresolved compilation problem:
The method load(InputStream) in the type Properties is not applicable for the arguments (Reader)
以下是本人代码:
try {
FileInputStream fis = new FileInputStream(filePath
+ "/config.properties");
Reader r = new InputStreamReader(fis, "UTF-8");//................................... 这里报错 ..........................................
props.load(r);
//....................................................................................... Iterator it = props.keySet().iterator();
while (it.hasNext()) {
String key = (String) it.next();
logger.info("config.properties key:" + key);
configMap.put(key, props.get(key));
}
} catch (Exception ex) {
logger.error(ex.getMessage());
}
java.io.InputStream is = PropertyUtil.class
.getResourceAsStream(propertyFilePath);
if (is == null) {
return loadPropertyFileByFileSystem(propertyFilePath);
}
Properties ppts = new Properties();
try {
ppts.load(is);
return ppts;
} catch (Exception e) {
_log.debug("加载属性文件出错:" + propertyFilePath, e);
return null;
}这样试试
具体楼主还是跟踪下吧
The method load(InputStream) in the type Properties is not applicable for the arguments (Reader)而再上面发送事件给监听者有异常,可能就是因这个错误引起的事件都未初始化完成或初始化错误导致的发送异常