我是靠谱客的博主 细腻啤酒,这篇文章主要介绍springBoot:Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire fi,现在分享给大家,希望可以做个参考。

Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.wn.boot.dao.PersonRespository com.wn.boot.test.GirlController.personRespository; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.wn.boot.dao.PersonRespository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) ~[spring-beans-4.2.7.RELEASE.jar:4.2.7.RELEASE]

... 17 common frames omitted



解决方法:

springBoot入口类(main函数所在类)的包名为com.wn.test

则dao层和service的类放在com.wn.test下或子包下才能被扫描到。

最后

以上就是细腻啤酒最近收集整理的关于springBoot:Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire fi的全部内容,更多相关springBoot:Caused内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(47)

评论列表共有 0 条评论

立即
投稿
返回
顶部