java-No exception of type ConfigurationException can be thrown; an exception type must be a subclass of Throwable

功能:读配置文件

java菜鸟:导入工程在报名处就开始报错,第一次遇到

import org.apache.commons.lang3.StringUtils;

import org.apache.commons.configuration.ConfigurationException;

package com.test;

The type org.apache.commons.lang.exception.NestableException cannot be resolved. It is indirectly referenced from required .class files

catch (ConfigurationException e)

No exception of type ConfigurationException can be thrown; an exception type must be a subclass of Throwable

原因:

http://hi.baidu.com/virackt/item/8534b95d49ce78d4d48bac4d

No exception of type ConfigurationException can be thrown; an exception type must be a subclass of Throwable

后来查了一下居然是因为这个类里面定义的configurationException是继承了lang里面的NestableException

要同时引入两个包才能使用这个类。貌似apache很多jar包都是相互牵连,用一个功能就得加载好几个包

由于lang3中已经没有NestableException这个异常类了,所以使用configuration会出现异常,所以改用lang2.6问题就解决了

总结:

使用configuration,要有对用版本lang才可以

原文地址:https://www.cnblogs.com/Pierre-de-Ronsard/p/3985942.html