mybaits 报错没有getter或者setter方法


org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'menu' in 'class xxxx.Permission'

首先看到这个错误我立马去检查了对应的model.

@TableName("sys_permission") public class Permission implements Serializable { private static final long serialVersionUID = 4368792338865943489L; @TableId(value = "https://www.it610.com/article/id", type = IdType.AUTO) private Integer id; /** 应用ID */ @TableField(value = "https://www.it610.com/article/appId") private Integer appId; /** 父ID */ @TableField(value = "https://www.it610.com/article/parentId") private Integer parentId; /** 图标 */ @TableField(value = "https://www.it610.com/article/icon") @JSONField(serialize = false) private String icon; /** 名称 */ @TableField(value = "https://www.it610.com/article/name") private String name; /** 权限URL */ @TableField(value = "https://www.it610.com/article/url") @JSONField(serialize = false) private String url; /** 排序 */ @TableField(value = "https://www.it610.com/article/sort") private Integer sort = Integer.valueOf(1); /** 是否菜单 */ @TableField(value = "https://www.it610.com/article/isMenu") private Boolean isMenu; /** 是否启用 */ @TableField(value = "https://www.it610.com/article/isEnable") private Boolean isEnable; public Integer getAppId() { return this.appId; } public void setAppId(Integer appId) { this.appId = appId; } public Integer getParentId() { return this.parentId; } public void setParentId(Integer parentId) { this.parentId = parentId; } public String getIcon() { return icon; } public void setIcon(String icon) { this.icon = icon; } public String getName() { return this.name; } public void setName(String name) { this.name = name; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public Integer getSort() { return this.sort; } public void setSort(Integer sort) { this.sort = sort; } public Boolean getIsMenu() { return this.isMenu; } public void setIsMenu(Boolean isMenu) { this.isMenu = isMenu; } public Boolean getIsEnable() { return this.isEnable; } public void setIsEnable(Boolean isEnable) { this.isEnable = isEnable; } public String getUrlStr() { return url; } public String getPermissionIcon() { return icon; } public Integer getpId() { return this.parentId; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } }

(说明,我使用了mybatis-plus,模型里的注解都是mybatis-plus的)
什么鬼?我的mode里面根本就没有menu这个属性!!!。但是我我发现了isMenu这个属性,那么问题会不会出在这里呢?
继续百度。。。。。。。。。。。。。。。。。。。。。。。
最后发现
mybatis会将is开头并且是Boolean类型的属性进行单独处理,只要做如下修改
public Boolean getMenu() { return this.isMenu; } public void isMenu(Boolean isMenu) { this.isMenu = isMenu; }

【mybaits 报错没有getter或者setter方法】这样它便能读取和设置对应的属性了,其实在spring mvc中接收is开头并且是Boolean类型的参数也要注意get和set方法的写法。
具体为啥要这样,那得去问歪果仁了。。。。。。。。

    推荐阅读