Spring Boot启动报错:Failed to instantiate [ClassName]: No default constructor found;
来源:互联网 发布:知行青年网 编辑:程序博客网 时间:2024/06/10 08:45
今天在Spring Boot工程启动时报错了,提示不能初始化该类,原因是找不到默认的构造方法,我看了一下,我也有写构造方法:
public class H2DbOperation extends AbstractDbOperation{public H2DbOperation(String url, String name, String password, Connection connection, String driver) {super(url, name, password, connection, driver);}
但是还报这样的错,后来才恍然大悟,原来在使用注解把类注解为Bean时,默认的构造方法是无参构造方法,
解决办法是在抽象父类中添加无参构造方法,然后在子类中也添加无参构造方法即可
父类构造方法
public AbstractDbOperation() {}
子类构造方法
public H2DbOperation() {super();}
这样就不会报错了,在使用构造方法的时候应该要注意这一点。
0 0
- Spring Boot启动报错:Failed to instantiate [ClassName]: No default constructor found;
- 使用Spring报错:No default constructor found;
- spring boot启动报错:No active profile set, falling back to default profiles: default
- Could not instantiate bean class [com.bjsxt.service.UserService]: No default constructor found;
- X-code报错: Failed to instantiate the default view controller for UIMainStoryboardFile 'Main'
- SpringBoot 启动服务器失败 报错 spring-boot Failed to start component [StandardServer[-1]]
- xcode6新建项目,删除mainstoryboard,新建storyboard报错:failed to instantiate the default view controller for ...
- Failed to instantiate the default view controller
- Failed to instantiate the default view controller
- Failed to instantiate the default view controller
- 启动virtualbox报错Failed to instantiate CLSID_VirtualBox w/ IVirtualBox, but CLSID_VirtualBox w/ IUnknow
- Hibernate报错:No default constructor for entity xxx
- spring No default constructor found; nested exception is java.lang.NoSuchMethodException: com.slj.mo
- Mybatis 报错 No constructor found in xx类
- Mybatis 报错 No constructor found in xx类
- Failed to instantiate * using constructor public * with arguments **
- Spring Boot启动报错Unable to start embedded Tomcat
- Spring Boot启动报错Unable to start embedded Tomcat
- Ubuntu的wired Networks 变灰色,无法连接网络
- android 项目学习随笔十二(ListView加脚布局)
- android 项目学习随笔十三(ListView实现ITEM点击事件)
- android 项目学习随笔十四(WebView)
- android 项目学习随笔十五(ShareSDK开放平台)
- Spring Boot启动报错:Failed to instantiate [ClassName]: No default constructor found;
- android 项目学习随笔十六( 广告轮播条播放)
- ListView自定义适配器
- android 项目学习随笔十七(ListView、GridView显示组图)
- 微信小程序(六):列表上拉加载下拉刷新
- ViewDragHelper使用介绍
- android 项目学习随笔十八(三级缓存)
- java源文件结构
- Java23种设计模式的研究之一(工厂方法模式(Factory Method))