问题描述

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-01-23 17:44:38.171 ERROR 27300 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : ***************************
APPLICATION FAILED TO START
***************************Description:Field jobinfodao in club.zstuca.service.impl.JobInfoServiceImpl required a bean of type 'club.zstuca.dao.JobInfoDao' that could not be found.The injection point has the following annotations:- @org.springframework.beans.factory.annotation.Autowired(required=true)Action:Consider defining a bean of type 'club.zstuca.dao.JobInfoDao' in your configuration.Process finished with exit code 0

其他类似:

No qualifying bean of type 'xxx.xxx.xxx' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}

或:

Not a managed type: class xxx.xxx.xxx

问题分析

由于SpringBoot默认扫描SpringBoot 入口类所在的包及其子包中,所以没有扫描到其他包(兄弟包、父包)的JpaRepository 子接口

解决方案

方案一

@SpringBootApplication 注解的 SpringBoot 入口类移到上层 root 包中,使 JpaRepository 子接口位于 root 包及其子包中。

方案二

SpringBoot 入口类上添加

(1) @ComponentScan(basePackages = "xxx.xxx.xxx"):扫描 @Controller、@Service 注解;(或者 @Component

(2) @EnableJpaRepositories(basePackages = "xxx.xxx.xxx"):扫描 @Repository 注解;

(3) @EntityScan(basePackages = "xxx.xxx.xxx"):扫描 @Entity 注解;

参考文章

https://blog.csdn.net/guokexiaohao/article/details/79741023

https://stackoverflow.com/questions/40384056/consider-defining-a-bean-of-type-package-in-your-configuration-spring-boot

https://blog.csdn.net/qq_38061755/article/details/80724970

https://blog.csdn.net/u014745069/article/details/78801405

Spring Boot——[JPA 无法注入 JpaRepository 子接口问题]解决方案相关推荐

  1. Spring Boot JPA 2.7.2

    icon: edit date: 2022-01-02 category: CategoryA tag: tag A tag B star: true Spring Boot JPA 2.7.2 项目 ...

  2. 使用Spring Boot JPA Specification实现使用JSON数据来查询实体数据

    文章目录 使用Spring Boot JPA Specification实现使用JSON数据来查询实体数据 需求概要 JSON 结构的设计 使用策略模式执行不同的查询条件 构造查询条件 主逻辑具体的代 ...

  3. Spring Boot Jpa 配置多个数据源,并读取其中一个表的具体数据

    总体简介: Spring Boot Jpa配置多个数据源(此次两个mysql数据库),访问其中一个库 alime_counsel_assign_log下的assign_data_backflow表,实 ...

  4. (转)Spring Boot(五):Spring Boot Jpa 的使用

    http://www.ityouknow.com/springboot/2016/08/20/spring-boot-jpa.html 在上篇文章Spring Boot(二):Web 综合开发中简单介 ...

  5. Spring Boot (十五): Spring Boot + Jpa + Thymeleaf 增删改查示例

    <p>这篇文章介绍如何使用 Jpa 和 Thymeleaf 做一个增删改查的示例.</p> 先和大家聊聊我为什么喜欢写这种脚手架的项目,在我学习一门新技术的时候,总是想快速的搭 ...

  6. Spring Boot JPA的查询语句

    文章目录 准备工作 Containing, Contains, IsContaining 和 Like StartsWith EndsWith 大小写不敏感 Not @Query Spring Boo ...

  7. Spring Boot JPA中使用@Entity和@Table

    文章目录 默认实现 使用@Table自定义表格名字 在JPQL Queries中重写表格名字 Spring Boot JPA中使用@Entity和@Table 本文中我们会讲解如何在Spring Bo ...

  8. Spring Boot JPA中java 8 的应用

    文章目录 Optional Stream API CompletableFuture Spring Boot JPA中java 8 的应用 上篇文章中我们讲到了如何在Spring Boot中使用JPA ...

  9. Spring Boot+JPA 有查询条件的查询

    本篇介绍使用JPA 的条件查询, 关于JPA基本查询可以参考: Spring Boot+JPA 查询数据方式与代码演示 不安全的查询 在开发时, 为了简便, 习惯会拼接Where子句的查询条件, 查询 ...

最新文章

  1. golang管道channel的遍历和关闭:应该使用for...range来遍历
  2. CAS5.2x单点登录(一)——搭建cas服务器
  3. 计算机精英协会考核题 —— 第三题:斐波那契数
  4. xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance(xsi:schemaLocation详解)
  5. Cordova插件中JavaScript代码与Java的交互细节介绍
  6. windows脚本编制引擎_说说 Windows 脚本宿主运行的几种方式
  7. Linux Ubuntu搭建git服务器
  8. 创建oracle管理用户名和密码是什么情况,Oracle创建时默认创建的用户以及密码
  9. apach2.2+php5.35 windows环境下安装问题解决
  10. 2015-2016书籍计划
  11. GPRS RTU设备OPC Server接口C# 实现
  12. 服务器性能与功率,服务器电源功率并非越大越好
  13. 国产服务器虚拟化产品,国内主流虚拟化厂商之间比较.doc
  14. android设备登录是什么手机_Android手机丢失或被盗?现在就告诉你如何找回它
  15. 独木舟贪心算法c语言,算法:(贪心算法)-独木舟问题
  16. error c2678解决方法
  17. 不用PS,一键生成熊猫头表情包
  18. 怎样解决spoolsv.exe应用程序错误
  19. SpringCloud版本介绍
  20. Python中的array[:]表示什么意思?记录一个幺蛾子

热门文章

  1. softmax函数_干货 | 浅谈 Softmax 函数
  2. sql网站路径php,如何在源码中找出sql语句的位置呢
  3. java如何解析json_java 中解析json步骤
  4. 1151压力变送器型号_罗斯蒙特变送器的标准精度!
  5. java 位运算符赋值_java-运算符(算术、赋值 =、关系、逻辑、三元、位运算符)...
  6. cad加载插件快捷键命令_cad自动加载lsp插件,这一种方法你肯定没用过!
  7. python的本质,讨论 - 廖雪峰的官方网站
  8. pythondir什么意思_Python之dir()与__dict__的区别
  9. java语言编程基础_Java编程基础02——Java语言基础
  10. Android将数据库数据导出成excel格式的文本(CSV)