java.lang.NoSuchMethodException: cn.pb.bean.Category.<init>()报错
代码如下:
package cn.pb.bean; import java.util.ArrayList;
import java.util.List; /**
* 分类的实体类
*/
public class Category {
private Integer cid;
private String cname;
private Integer pid; //父分类下子分类的集合
private List<Category> list = new ArrayList<Category>(); public Integer getCid() {
return cid;
} public void setCid(Integer cid) {
this.cid = cid;
} public String getCname() {
return cname;
} public void setCname(String cname) {
this.cname = cname;
} public Integer getPid() {
return pid;
} public void setPid(Integer pid) {
this.pid = pid;
} public List<Category> getList() {
return list;
} public void setList(List<Category> list) {
this.list = list;
} public Category(Integer cid, String cname, Integer pid, List<Category> list) {
this.cid = cid;
this.cname = cname;
this.pid = pid;
this.list = list;
} @Override
public String toString() {
return "Category{" +
"cid=" + cid +
", cname='" + cname + '\'' +
", pid=" + pid +
", list=" + list +
'}';
}
} 最后发现是我在代码最后写了个有参构造,重载了构造函数,而Mybatis在load进一个bean类时,需要无参构造从而导致了该错误, 解决方法,给代码加上午参构造即可!
public Category() {
super();
}
java.lang.NoSuchMethodException: cn.pb.bean.Category.<init>()报错的更多相关文章
- Android 编程下 java.lang.NoClassDefFoundError: cn.jpush.android.api.JPushInterface 报错
使用了极光推送的 jar 包项目在从 SVN 中检出后,假设不又一次对 jar 包和 Bulid Path 进行配置就会抛出 java.lang.NoClassDefFoundError: cn.jp ...
- 日常报错记录2: MyBatis:DEBUG [main] - Logging initialized using 'class org.apache.ibatis.logging.slf4j.Slf4jImpl' adapter.------------ Cause: java.lang.NoSuchMethodException: com.offcn.dao.ShopDao.<init>()
直接上干货: 报错归纳1: DEBUG [main] - Logging initialized using 'class org.apache.ibatis.logging.slf4j.Slf4 ...
- Caused by: java.lang.InstantiationException: cn.at.bean.domain.ConstantInt
org.springframework.jdbc.UncategorizedSQLException: ConnectionCallback; uncategorized SQLException ...
- java.lang.NoClassDefFoundError: org/apache/commons/collections/FastHashMap报错解决
在使用 commons-beanutils-1.9.2.jarcommons-logging-1.1.1.jar 的时候报错 java.lang.NoClassDefFoundError: org/a ...
- java.lang.ClassNotFoundException: org.apache.commons.fileupload.FileItemFactory报错springmvc
转自:https://blog.csdn.net/qq_41879385/article/details/82892555 下面是错误信息:java.lang.ClassNotFoundExcepti ...
- (已解决)java.lang.NoSuchMethodException: com.kevenwu.pojo.User.<init>()
搭建ssm框架时报了如下错误,原因是: mybatis在初始化bean的时候需要无参构造器, 如果写了有参构造器,将会把无参构造器覆盖掉,加上一个无参构造器就可以了
- “java.lang.IllegalArgumentException: Failed to evaluate expression ‘ROLE_USER’”报错的解决
这个问题出现在Spring Security的相关配置中,找到原来的这一行: <security:intercept-url pattern="/**" access=&qu ...
- java.lang.NoSuchMethodException: .<init>()
严重: Servlet.service() for servlet [springmvc] in context with path [/SpringMvc-1] threw exception [R ...
- org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.hs.model.StudentModel]: No default constructor found; nested exception is java.lang.NoSuchMethodException: c
root cause org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [c ...
随机推荐
- 转:PCIe基础知识
PCIe基础知识 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/zqixiao_09/article/details/51842542 PCIe ...
- mysql索引类型normal,unique,full text
normal:表示普通索引 unique:表示唯一的,不允许重复的索引,如果该字段信息保证不会重复例如身份证号用作索引时,可设置为unique full textl: 表示 全文搜索的索引. FULL ...
- java 中的CountDownLatch
直接使用thread可以使用thread和wait notify 实现顺序执行 线程池中可以使用CountDownLatch 进行顺序执行 package com.test; import java. ...
- mybatis前台传来一个String,后后台执行sql变成了true
实际上参数传来的是一个字符串 3 ,不知道为什么会变成true 最后当然是查不到信息了.. 我在mapper映射文件里面使用了动态的where查询,我觉得跟这个关系不太大, 现在不知道怎么办,希望有思 ...
- 【转】【Pycharm大全】
感谢:陈俊岭的程序员之路 [Pycharm大全]:http://blog.csdn.net/u013088062/article/details/50388329
- eclipse没有(添加)"Dynamic Web Project"选项的方法
建议使用代理lantern,否则可能要花很长时间显示和下载插件 http://www.dabu.info/eclipse-no-add-dynamic-web-project-option.html ...
- EF6&EFCore 注册/使用实体类的正确姿势
首先回顾下EF中常规使用流程 1.新建实体类以及实体配置(data annotation或fluent api) [Table("Users")] public class Use ...
- C++复习:位运算
与 a&b : 1010&1100=1000 或 a|b : 1010|1100=1110 异或 a^b : 101 ...
- iphone开发之获取网卡的MAC地址和IP地址
本文转载至 http://blog.csdn.net/arthurchenjs/article/details/6358489 这是获取网卡的硬件地址的代码,如果无法编译通过,记得把下面的这几个头文件 ...
- Unix环境高级编程第三版中实例代码如何在自己的linux上运行的问题
学习Linux已经有2个月了,最近被期末考试把进度耽误了,前几天把Unix环境高级编程看了两章,感觉对Linux的整体有了一些思路,今天尝试着对第一章涉及到的一个简单的交互式shell编译运行一下,结 ...