Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name


目前有發現的兩種情況

第一種:是在繼承jpa的時候檢查實體類@id和@Entity引進的包是否是

import javax.persistence.Id
imprt javax.persistence.Entity;
import javax.persistence.Table;

第一次引進很容易引錯包下面是錯誤的包

org.springframework.data.annotation.Id;

要不然你就得去找找你的dao與service的注解是不是漏掉了

第二種:情況屬於比較少見的

無法注入Dao中的Bean!

SpringBoot項目的Bean裝配默認規則是根據Application類所在的包位置從上往下掃描! “Application類”是指SpringBoot項目入口類。這個類的位置很關鍵:
如果Application類所在的包為:com.ssm.springboot
,則只會掃描com.ssm.springboot
包及其所有子包,如果service或dao所在包不在com.ssm.springboot
及其子包下,則不會被掃描!

 

這種情況也會導致注入不進去的錯誤

解決辦法

將SpringbootApplication放在要掃描包包中

一定不要如下圖另起一個包要不然

@ComponentScan他也救不了你

最簡單的你是這樣了

 

放置於自動掃描包的同一包名下

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



猜您在找 SpringBoot 報 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bootstrapImportSelectorConfiguration': Initialization of bean failed; Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fundService': Injection of resource dependencies failed; org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'configurationPropertiesBeans' defined in class path resource org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'multipartResolver': Failed to introspect bean class [org.springframework.web.multipart.commons.CommonsMultipartR Spring AOP 報錯org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'XXXXXX' defined in class path resource.......... 使用security報錯:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource ssm整合時出現 org.springframework.beans.factory.BeanCreationException :Error creating bean with name ‘XXX’ 異常的原因及解決方法 ssm整合時出現 org.springframework.beans.factory.BeanCreationException :Error creating bean with name ‘XXX’ 異常的原因及解決方法 spring測試出錯:Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0':
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM