读书人

请问一下 为什么我在用 PropertyUti

发布时间: 2011-12-25 23:21:20 作者: rapoo

请教一下各位高手, 为什么我在用 PropertyUtils.getPropertyType 的时候会出现java.lang.NoClassDefFoundError 的错误? 谢谢!!!
请教一下各位高手, 为什么我在用 PropertyUtils.getPropertyType 的时候会出现java.lang.NoClassDefFoundError 的错误? 谢谢!!!

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import org.apache.commons.beanutils.PropertyUtils;

public class Test {

public static void main(String[] args)
{
Chapter chapter = new Chapter();
// 下面将出个这个name属性的类型,String

chapter.setName( "xxxxxxxxxx ");

ArrayList chapters = new ArrayList();
chapters.add(chapter);

Book book2 = new Book();
book2.setChapters(chapters);

Class type2 = null ;

System.out.println( "here ");
try {
type2 = PropertyUtils.getPropertyType(book2, "chapters[0].name ");
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


System.out.println(type2.getName());
}
}


输出的显示是:
here
Exception in thread "main " java.lang.NoClassDefFoundError: org/apache/commons/collections/FastHashMap
at org.apache.commons.beanutils.PropertyUtils. <clinit> (PropertyUtils.java:208)
at Test.main(Test.java:30)

[解决办法]
顶,,,,,,,我也想知道..

读书人网 >Eclipse开发

热点推荐