请教一下各位高手, 为什么我在用 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)
------解决方案--------------------
顶,,,,,,,我也想知道..