相关疑难解决方法(0)

Java中的ConfigurationException?

决定使用Apache的Common Configuration包来解析XML文件.

我决定做一个:

XMLConfiguration xmlConfig = new XMLConfiguration(file);
Run Code Online (Sandbox Code Playgroud)

Eclipse抱怨我没有捕获异常(Unhandled exception type ConfigurationException),所以我点击了可靠性surround with try/catch并添加了以下代码:

try 
    {
        XMLConfiguration xmlConfig = new XMLConfiguration(file);
    } 
    catch (ConfigurationException ex) 
    {
        ex.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

然而现在它抱怨:

No exception of type ConfigurationException can be thrown; an exception type 
must be a subclass of Throwable
Run Code Online (Sandbox Code Playgroud)

我不明白为什么当Eclipse是建议添加它时,它给了我这个错误.

java apache-commons

23
推荐指数
3
解决办法
5万
查看次数

标签 统计

apache-commons ×1

java ×1