简体   繁体   English

尽管班级正确,为什么还会出现此错误?

[英]Why does this error appear in spite of correct class?

This is the error message: 这是错误消息:

org.springframework.web.util.NestedServletException: Request processing failed; org.springframework.web.util.NestedServletException:请求处理失败; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: Could not set property 'nWriteDate' of 'class com.tj.notice.model.Notice1' with value '2018-02-12 15:17:54.0' Cause: org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'nWriteDate' in 'class com.tj.notice.model.Notice1' 嵌套的异常是org.mybatis.spring.MyBatisSystemException:嵌套的异常是org.apache.ibatis.reflection.ReflectionException:无法设置值为“ 2018-02”的com.tj.notice.model.Notice1类的属性“ nWriteDate” -12 15:17:54.0'原因:org.apache.ibatis.reflection.ReflectionException:在com.tj.notice.model.Notice1类中没有名为“ nWriteDate”的属性的设置器

Class Notice1 : 上课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;
    }   
}

Why does this error appear in spite of correct class? 尽管班级正确,为什么还会出现此错误?

When you meet an exception, be patient to it. 当您遇到例外时,请耐心等待。 It says "There is no setter for property named 'nWriteDate' in 'class com.tj.notice.model.Notice1'". 它说:“类'com.tj.notice.model.Notice1'中没有名为'nWriteDate'的属性的设置器”。

You need to change 你需要改变

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

to

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

Often you can avoid this kind of error by generate getter and setter by IDE, such as eclipse, intellij. 通常,您可以通过IDE生成getter和setter来避免此类错误,例如eclipse,intellij。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM