1. 程式人生 > 其它 >記錄一個錯誤Error creating bean with name ‘cdPhotogrBasicController‘ defined in file

記錄一個錯誤Error creating bean with name ‘cdPhotogrBasicController‘ defined in file

記錄一個錯誤Error creating bean with name ‘cdPhotogrBasicController’ defined in file

問題描述

專案在啟動時建立Bean報錯

報錯資訊

Error creating bean with name "XXX"

以及

Cannot find class: org.springblade.flow.video.entity.CdPhotogrBasic

解決方案

最主要的就是下邊的這個報錯其實最主要的就是第二個報錯

  1. 是否忘了加@Controller和@Service註釋
  2. 是否正確配置了掃描包的位置
  3. 比對自己專案中檔案的路徑
    由於我的專案一開始是做的單體應用,現在要上微服務了,我就直接把一些程式碼直接考到新建的模組內了導致路徑不一致了
    這是我新專案下的路徑
    在這裡插入圖片描述
    這是我mapper裡的路徑,明顯報錯並多了一層,修改後成功啟動在這裡插入圖片描述

總結

做專案時一定要認真比對自己的路徑,無論是註解還是配置,不要因為一時疏忽然後花上大量的時間去找錯誤。