今天使用BeanUtils操作javaBean的时候,相关的jar文件都已经导进去了,可是在执行的时候总是报错,
ReflectPoint p = new ReflectPoint(3,4);
System.out.println(BeanUtils.getProperty(p,“x”));
报错如下:
Exception in thread "main" java.lang.NoSuchMethodException: Property 'x' has no getter method in class 'class ReflectPoint'
at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1327)
at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:770)
at org.apache.commons.beanutils.BeanUtilsBean.getNestedProperty(BeanUtilsBean.java:715)
at org.apache.commons.beanutils.BeanUtilsBean.getProperty(BeanUtilsBean.java:741)
at org.apache.commons.beanutils.BeanUtils.getProperty(BeanUtils.java:382)
at Testx3.main(Testx3.java:28)
这是怎么回事,那个ReflectPoint类里面有属性x的get方法呀,为什么会报这样的错呢 |
|