try
{
XMLConfiguration xmlConfig = new XMLConfiguration(file);
}
catch (ConfigurationException ex)
{
ex.printStackTrace();
}
出现错误:
No exception of type ConfigurationException can be thrown; an exception type
must be a subclass of Throwable
问题是因为Apache Commons Configuration 依赖于下列包:
- Apache Commons Lang (version 2.2, 2.3, 2.4, 2.5 or 2.6)
- Apache Commons Collections (version 3.1, 3.2 or 3.2.1)
- Apache Commons Logging (version 1.0.4, 1.1 or 1.1.1)
注意,使用最新的3.1版的Apache Commons Lang不能解决问题,使用2.6版的可以。
本文探讨了在使用Apache CommonsConfiguration加载XML配置文件时遇到的异常问题,指出问题原因在于Apache CommonsLang版本不匹配,并提供了有效的解决方案,推荐使用2.6版本的Apache CommonsLang来解决该问题。

3887

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



