Java中的ConfigurationException? [英] ConfigurationException in Java?
问题描述
决定使用Apache的Common Configuration包来解析XML文件。
我决定做一个:
XMLConfiguration xmlConfig = new XMLConfiguration(file);
Eclipse抱怨我没有捕到异常(未处理的异常输入ConfigurationException
),所以我用try / catch 命中了可靠的环绕声,并添加了以下代码:
尝试
{
XMLConfiguration xmlConfig = new XMLConfiguration(file);
}
catch(ConfigurationException ex)
{
ex.printStackTrace();
}
然而现在它正在抱怨:
不能抛出ConfigurationException类型的异常;异常类型
必须是Throwable的子类
我不明白为什么给它Eclipse是建议添加它的那个错误。
org.apache.commons .configuration.ConfigurationException
extends org.apache.commons.lang.exception.NestableException
。
<你在路上也有Commons Lang吗?如果没有,Eclipse将无法解析
ConfigurationException
类,您将收到该错误。 Decided to use Apache's Common Configuration package to parse an XML File.
I decided to do a:
XMLConfiguration xmlConfig = new XMLConfiguration(file);
To which Eclipse complained that I haven't caught an exception(Unhandled exception type ConfigurationException
), so I hit the trusty surround with try/catch
and it added the following code:
try
{
XMLConfiguration xmlConfig = new XMLConfiguration(file);
}
catch (ConfigurationException ex)
{
ex.printStackTrace();
}
However now it's complaining:
No exception of type ConfigurationException can be thrown; an exception type
must be a subclass of Throwable
I don't understand why it's gave me that error when Eclipse is the one that suggested to add it.
org.apache.commons.configuration.ConfigurationException
extends org.apache.commons.lang.exception.NestableException
.
Do you have Commons Lang on your path also? If not, Eclipse will fail to resolve the ConfigurationException
class, and you'll get that error.
这篇关于Java中的ConfigurationException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!