当前位置: 首页 > news >正文

堵博网站建设希爱力

堵博网站建设,希爱力,python做的网站多吗,新手做地方门户网站Spring报错详解 一、前言二、报错提示三、分层解读1.最下面一层Caused by2.上一层Caused by3.最上层Caused by 四、总结五、解决方案 一、前言 本文主要是记录在初次学习Spring时遇到报错后的解读以及解决方案 二、报错提示 三、分层解读 遇到报错的时候,我们需要…

Spring报错详解

  • 一、前言
  • 二、报错提示
  • 三、分层解读
    • 1.最下面一层Caused by
    • 2.上一层Caused by
    • 3.最上层Caused by
  • 四、总结
  • 五、解决方案

一、前言

本文主要是记录在初次学习Spring时遇到报错后的解读以及解决方案

二、报错提示

在这里插入图片描述

三、分层解读

遇到报错的时候,我们需要从下往上阅读错误,从最下面一层的Caused by开始阅读,最核心的错误是在最下面一层的;最上面 Exception in....是对下面的错误的包装

1.最下面一层Caused by

在这里插入图片描述

Caused by: java.lang.NoSuchMethodException: com.itheima.dao.impl.BookDaoImpl.

NoSuchMethodException:没有这样的方法导致的异常

在这句话后面列出了一个方法:com.itheima.dao.impl.BookDaoImpl.<init>(),也就是缺失了这个方法导致的异常报错

2.上一层Caused by

在这里插入图片描述

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.itheima.dao.impl.BookDaoImpl]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.itheima.dao.impl.BookDaoImpl.<init>()

BeanInstantiationException:Bean实例化异常

Failed to instantiate:实例化失败,在中国报错后面给了一个类com.itheima.dao.impl.BookDaoImpl,表示这个类实例化失败

No default constructor found:未找到默认构造函数

nested:嵌套,嵌套下一层的报错

3.最上层Caused by

在这里插入图片描述

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bookDao' defined in class path resource [applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.itheima.dao.impl.BookDaoImpl]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.itheima.dao.impl.BookDaoImpl.

这里我们只要看nested前的报错信息即可

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bookDao' defined in class path resource [applicationContext.xml]: Instantiation of bean failed

BeanCreationException:创建Bean异常:后面写出创建哪一个Bean失败了

Error creating bean with name 'bookDao' defined in class path resource [applicationContext.xml]:在applicationContext.xml文件里名字为bookDaoBean创建失败

Instantiation of bean failed:Bean实例化失败

四、总结

这个报错原因很清晰:在 com.itheima.dao.impl.BookDaoImpl这个类中缺少默认构造函数,这里给出 com.itheima.dao.impl.BookDaoImpl类的代码


public class BookDaoImpl implements BookDao {public BookDaoImpl(int i) {System.out.println("book dao constructor is running ....");}public void save() {System.out.println("book dao save ...");}}

可以看出这里缺少不含参数的构造函数public BookDaoImpl()

五、解决方案

  1. 在原有代码上加上如下代码

    public BookDaoImpl(){}
    
  2. 修改含参构造方法,去掉int i

    public BookDaoImpl(){}
    
http://www.hkea.cn/news/674413/

相关文章:

  • 如何将自己做的网页做成网站绍兴seo
  • 河南省住房与城乡建设厅网站首页怎么做属于自己的网站
  • 移动端网站开发推广效果最好的平台
  • 用二级页面做网站的源代码自助建站系统破解版
  • 网站上怎么做动画广告推广策略包括哪些内容
  • 广州网站优化公司大亚湾发布
  • 广州网站开发招聘百度经验悬赏令
  • 吴江建设局网站郑州粒米seo外包
  • 建设工程合同纠纷与劳务合同纠纷seo培训教程视频
  • 找网站建设公司哪家最好沈阳市网站
  • sh域名做的好的网站什么是营销
  • 网站平台怎么做推广一站式网络推广服务
  • 百度对新网站排名问题兰州seo快速优化报价
  • 网站建设常用代码湘潭网络推广
  • 做网站上传图片一直错误好用搜索引擎排名
  • 钟祥网站建设网络推广的含义
  • 新闻类网站源码青岛官网seo
  • 网站优化哪里可以做百度营销客户端
  • 常德建设局网站北京优化网站方法
  • 用ip做网站优化手机流畅度的软件
  • 为网站添加统计媒介
  • 商业设计网站推荐互联网营销师证书是国家认可的吗
  • 做网站的是干嘛的怎样把自己的产品放到网上销售
  • 品牌型网站制作价格2022年小学生新闻摘抄十条
  • 政府网站群集约化建设网络暴力事件
  • 可以做卷子的网站游戏app拉新平台
  • 长沙优化网站关键词社区营销
  • 个人网站制作价格表重庆关键词优化
  • 网站开发ideseo优化网站模板
  • 关于制作网站收费标准怎样把个人介绍放到百度