本帖最后由 刘胜寒 于 2013-5-24 14:41 编辑
- import java.lang.reflect.InvocationTargetException;
- import java.util.Date;
- import org.apache.commons.beanutils.BeanUtils;
- class exam{
- public Date birthday = new Date();
- public Date getBirthday() {
- return birthday;
- }
- public void setBirthday(Date birthday) {
- this.birthday = birthday;
- }
- }
- public class JavaBean {
- /**
- * @param args
- * @throws InvocationTargetException
- * @throws IllegalAccessException
- */
- public static void main(String[] args) throws Exception {
- // TODO Auto-generated method stub
- exam e = new exam();
- // e.birthday = new Date(10000);
- BeanUtils.setProperty(e, "birthday.time", "111");
- System.out.println(e.getBirthday());
- System.out.println(BeanUtils.getProperty(e, "birthday.time"));
- System.out.println(e.getBirthday());
- }
- }
复制代码 执行地三十三行代码报错:
Exception in thread "main" java.lang.NoSuchMethodException: Property 'birthday' has no getter method in class 'class eud.hhtc.Day_2.exam'
机器配置:JDK1.6 运行环境也是1.6
这不科学啊。。
张孝祥老师没报错啊。。
昨天在JDK1.7 运行环境1.6中提示抛出的一场信息,和上面的不一致。
求高人解答?
|