尽管正确上课,为什么会出现此错误?

时间:2018-02-13 09:23:55

标签: java spring

这是错误消息:

  

org.springframework.web.util.NestedServletException:Request   处理失败;嵌套异常是   org.mybatis.spring.MyBatisSystemException:嵌套异常是   org.apache.ibatis.reflection.ReflectionException:无法设置   属性'nWriteDate'的'class com.tj.notice.model.Notice1'with   值'2018-02-12 15:17:54.0'原因:   org.apache.ibatis.reflection.ReflectionException:没有setter   对于'class com.tj.notice.model.Notice1'中名为'nWriteDate'的属性

班级Notice1

package com.tj.notice.model;

import java.sql.Timestamp;

public class Notice1 {

    private int nIdx;
    private String aID;
    private String nTitle;
    private String nContent;
    private Timestamp nWritedate;
    private int startRow;
    private int endRow;
    public int getnIdx() {
        return nIdx;
    }
    public void setnIdx(int nIdx) {
        this.nIdx = nIdx;
    }
    public String getaID() {
        return aID;
    }
    public void setaID(String aID) {
        this.aID = aID;
    }
    public String getnTitle() {
        return nTitle;
    }
    public void setnTitle(String nTitle) {
        this.nTitle = nTitle;
    }
    public String getnContent() {
        return nContent;
    }
    public void setnContent(String nContent) {
        this.nContent = nContent;
    }
    public Timestamp getnWritedate() {
        return nWritedate;
    }
    public void setnWritedate(Timestamp nWritedate) {
        this.nWritedate = nWritedate;
    }
    public int getStartRow() {
        return startRow;
    }
    public void setStartRow(int startRow) {
        this.startRow = startRow;
    }
    public int getEndRow() {
        return endRow;
    }
    public void setEndRow(int endRow) {
        this.endRow = endRow;
    }   
}

为什么在出现正确的课程时会出现此错误?

1 个答案:

答案 0 :(得分:2)

当您遇到异常时,请耐心等待。它说“'com.tj.notice.model.Notice1'中没有名为'nWriteDate'的属性的setter”。

您需要更改

public Timestamp getnWritedate() {
        return nWritedate;
    }
    public void setnWritedate(Timestamp nWritedate) {
        this.nWritedate = nWritedate;
    }

public Timestamp getNWritedate() {
        return nWritedate;
    }
    public void setNWritedate(Timestamp nWritedate) {
        this.nWritedate = nWritedate;
    }

通常可以通过IDE生成getter和setter来避免这种错误,例如eclipse,intellij。