解决:Parameter 0 of constructor in com.mise.smart.entity.HrmNoticeEntity required a bean of type 'java.lang.Integer' that could not be found.

  • 一·问题描述:
    • 1.做excel导出功能时,启动springboot项目失败,报错如下所示。
  • 二·问题原因:
    • 1.原因产生背景:
      • (1)实体类利用spring注解注入bean时,在springboot项目启动期间,spring会自动调用该类的构造方法进行注入IOC容器
      • (2)如果没有进行特殊配置,就会默认调用无参构造方法进行注入容器。
      • (3)如果实体类没有无参构造方法,spring就会去调用实体类的有参构造方法,如果此时IOC里面还没有对应的参数实例,那么就会报错,提示没有提供必要的构造参数。
    • 2.根本原因:实体类缺少无参构造方法
    • 3.直接原因:
      • (1)lombok插件的@Data注解,理解有偏差,实体类上面已经加了全参构造注解。
  • 三·解决办法:
    • 1.在实体类上面再加上lombok插件的无参构造注解
  • 四·测试结果:启动成功!

一·问题描述:

1.做excel导出功能时,启动springboot项目失败,报错如下所示。


二·问题原因:

1.原因产生背景:

(1)实体类利用spring注解注入bean时,在springboot项目启动期间,spring会自动调用该类的构造方法进行注入IOC容器

(2)如果没有进行特殊配置,就会默认调用无参构造方法进行注入容器。

(3)如果实体类没有无参构造方法,spring就会去调用实体类的有参构造方法,如果此时IOC里面还没有对应的参数实例,那么就会报错,提示没有提供必要的构造参数。

2.根本原因:实体类缺少无参构造方法

3.直接原因:

(1)lombok插件的@Data注解,理解有偏差,实体类上面已经加了全参构造注解。

lombok插件的@Data注解作用:
(1)在你没有显示声明有参构造方法的时候,它会自动给类加上必要的无参构造函数;
(2)如果你主动加上了有参构造方法,包括利用lombok插件的全参构造注解生成有参构造方法,@Data注解就不会再自动生成无参构造方法。
(3)其他作用如下图所示。

三·解决办法:

1.在实体类上面再加上lombok插件的无参构造注解

四·测试结果:启动成功!

解决:Parameter 0 of constructor in XXX required a bean of type ‘XXX‘ that could not be found相关推荐

  1. Parameter 1 of constructor in xxx required a bean of type xxx‘ that could not be found.已经解决

    使用Mybatis Plus 时遇到问题Parameter 1 of constructor in xxx required a bean of type xxx' that could not be ...

  2. springCloud Feign调用报错 Parameter 6 of constructor in xxxxxxxx required a bean of type ‘xxxxxx‘ that

    Description: Parameter 6 of constructor in xxxxxxx required a bean of type 'xxxxxxx' that could not ...

  3. springboot踩坑日记——Field xxx.xxx.xxx required a bean of type 'xxx.xxx.xxx' that could not be found

    使用feign时报创建的feign接口找不到 Field xxx.xxx.xxx required a bean of type 'xxx.xxx.xxx' that could not be fou ...

  4. springboot使用junit单元测试是发生报错 Field taskUtils in com.xxx.xxx.xxxx.xxx required a bean of type 'xxx.xxx.

    使用junit单元测试mybatis时发生如下错误 Error starting ApplicationContext. To display the conditions report re-run ...

  5. 使用Feign服务远程调用项目启动时报错:Field xxx in xxx required a bean of type xxx that could not be found.

    报错: *************************** APPLICATION FAILED TO START ***************************Description:F ...

  6. 解决:Parameter 0 of constructor in xxx required a bean of type ‘xxx‘ that could not be found.

    运行报错: Parameter 0 of constructor in com.xxx.Crawler required a bean of type 'java.lang.String' that ...

  7. Parameter 0 of constructor in XXX required a bean of type ‘XXX‘ that could not be found.

    今天在搭建微服务项目的时候遇到了一个问题 项目结构 实际的场景是OperationLogService需要注入OperationLogMapper,也就是最常见的业务层依赖数据层,但是项目启动的时候报 ...

  8. spring boot报错:Parameter 4 of constructor in xx required a bean of type ‘xx‘ that could not be found.

    spring boot 项目启动服务时,报错: 根据报错提示,一直认为是 SpringBootApplication 没有扫描到对应的 bean 路径. 最后,仔细排查发现是粗心的问题,自定义的常量没 ...

  9. 解决:Field xxClient in XXX required a bean of type 'XXX' that could not be found

    使用@Autowired导入client时报如下错误: 找不到这个client,于是到启动类里观察 @EnableFeignClients("")配置路径,发现果然不对: 修改后问 ...

最新文章

  1. usaco contact
  2. 微软算法100题11 求二叉树中两节点之间的最大距离
  3. Lucene-2.0学习文档
  4. STL sort解析
  5. WIX、Squarespace、WordPress 三者的优劣分别是什么?
  6. 步步高DVD机DV603的U盘模式支持视频格式
  7. vs code .lua.txt 后缀文件识别为lua的配置
  8. 微信新表情戒烟了!腾讯:雪茄大佬成了歪嘴战神
  9. 【干货】Python中几个有趣的函数
  10. c++11 多线程编程(五)------unique_lock
  11. 从B站源码泄露事件入手,说一下团队协作中版本管理的安全意识
  12. 百度离线语音合成SDK使用
  13. 【Mark】转正述职答辩
  14. 空间解析几何 | 经典例题、李林880例题
  15. 中国区块链专利申请数破万:阿里巴巴、联通、复杂美稳居前三甲
  16. 将CF卡移动磁盘标识改为本地磁盘标识的软件
  17. order by(排序查询结果)和LIMT
  18. 已知两点和切线如何确定圆心和半径长度
  19. 量子前沿英雄谱|IonQ联合创始人兼首席技术官Jungsang Kim
  20. CentOS升级PHP到8.0

热门文章

  1. CSS粘住底部的5种方法
  2. 微信小程序开发之大转盘 仿天猫超市抽奖
  3. s7300plc串口通信_基于LabVIEW的S7300PLC与PC机的串口通信.pdf
  4. 硬盘出现问题后会对计算机造成哪些影响,电脑硬盘坏道的影响有哪些?
  5. 卖家网:跨境电商数据查询,淘宝大学免费课程,淘宝电商培训班,电商资讯干货
  6. 分享一个美团大佬的面试笔记 - MySQL 30 问与答
  7. java医用物资信息管理系统 ssm
  8. lua中判断一个字符串是否是合法的ip地址格式
  9. 利用wikipedia 的API实现对其内容的查询
  10. vcenter vsphere HA一直初始化失败的原因