小编dar*_*gel的帖子

使用commons-beanutils会在org.apache.commons.logging.LogFactory上抛出ClassNotFoundException

我有相同的代码

import org.apache.commons.beanutils.PropertyUtils;
public class Reflection {

    private double []masElement = {3,5,2,5};

    public double getValue(int i){
    if (masElement.length>i){
    return masElement[i];
    }
    return 0;
    }
    public void setValue(int i, int value){
    if (masElement.length>i){
        masElement[i]=value;
    }
}
    public static void main(String[] args) {
    Reflection n = new Reflection();
    try {
        System.out.println(PropertyUtils.getProperty(n, "masElement[0]"));
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    } catch (NoSuchMethodException e) {
        e.printStackTrace();
    }
Run Code Online (Sandbox Code Playgroud)

我有问题,我不明白为什么?

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at org.apache.commons.beanutils.ConvertUtilsBean.<init>(ConvertUtilsBean.java:157)
at org.apache.commons.beanutils.BeanUtilsBean.<init>(BeanUtilsBean.java:117) …
Run Code Online (Sandbox Code Playgroud)

java

0
推荐指数
1
解决办法
2万
查看次数

标签 统计

java ×1