日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

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

發(fā)布時(shí)間:2024/10/5 javascript 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Spring Boot——[JPA 无法注入 JpaRepository 子接口问题]解决方案 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

問題描述

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默認(rèn)掃描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

總結(jié)

以上是生活随笔為你收集整理的Spring Boot——[JPA 无法注入 JpaRepository 子接口问题]解决方案的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。