public static void main(String[] args) throws Exception {
Student stu = new Student(22);
BeanUtils.setProperty(stu,"age",30);
}
}
复制代码
程序运行后,总是提示:Exception in thread "main" java.lang.reflect.InvocationTargetException: Cannot set age
Caused by: java.lang.NoSuchMethodException: Property 'age' has no setter method in class 'class cn.itcast.day3.Student'
Student类中不是已经有了getter和setter方法么,为何这里总提示说没有setter方法?