搜尋
首頁Javajava教程springboot啟動報錯bean找不到怎麼解決

    springboot啟動錯誤bean找不到的原因解決

    一.普通的dao,service對應的實例bean不存在

    錯誤範例:

    1.Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.

    Reason: Failed to determine a suitable driver class。

    解決方案:

    1.確實不存在,加進去就好了

    2.類別存在,但是spring沒有掃描到,注意啟動類別所在位置,springboot預設掃描的是啟動類別所在目錄下的子包和類,如下圖1.2所示。另外可以使用@componentScan這個註解指定掃描的套件:範例@componentScan({“xxx.xx”,“xxx.xx”})

    springboot啟動報錯bean找不到怎麼解決

    二.由於bean的載入順序與設定檔的關係

    1.請參考以下部落格文章

    https://www.yisu.com/article/222850.htm

    https:// www.yisu.com/article/190698.htm

    https://www.yisu.com/article/229466.htm

    補充:Springboot啟動錯誤之類文件具有錯誤的版本61.0, 應為52.0

    啟動Springboot專案時候報錯

    java: 無法存取org.springframework.boot.SpringApplication
    錯誤的類別檔案: /D:/Maven/apache-maven -3.6.3/repository/org/springframework/boot/spring-boot/3.0.0/spring-boot-3.0.0.jar!/org/springframework/boot/SpringApplication.class
    類別檔案具有錯誤的版本61.0, 應為52.0
    請刪除該檔案或確保該檔案位於正確的類別路徑子目錄中。

    springboot啟動報錯bean找不到怎麼解決

    原因

    SpringBoot使用了3.0或3.0以上,因為Spring官方發佈從Spring6以及SprinBoot3.0開始最低支援JDK17,所以只需將SpringBoot版本降低為3.0以下即可。

    springboot啟動報錯bean找不到怎麼解決

    將SpringBoot版本降低為3.0以下 版本隨意,刷新Maven重啟即可

    springboot啟動報錯bean找不到怎麼解決

    以上是springboot啟動報錯bean找不到怎麼解決的詳細內容。更多資訊請關注PHP中文網其他相關文章!

    陳述
    本文轉載於:亿速云。如有侵權,請聯絡admin@php.cn刪除

    熱AI工具

    Undresser.AI Undress

    Undresser.AI Undress

    人工智慧驅動的應用程序,用於創建逼真的裸體照片

    AI Clothes Remover

    AI Clothes Remover

    用於從照片中去除衣服的線上人工智慧工具。

    Undress AI Tool

    Undress AI Tool

    免費脫衣圖片

    Clothoff.io

    Clothoff.io

    AI脫衣器

    AI Hentai Generator

    AI Hentai Generator

    免費產生 AI 無盡。

    熱門文章

    R.E.P.O.能量晶體解釋及其做什麼(黃色晶體)
    1 個月前By尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O.最佳圖形設置
    1 個月前By尊渡假赌尊渡假赌尊渡假赌
    威爾R.E.P.O.有交叉遊戲嗎?
    1 個月前By尊渡假赌尊渡假赌尊渡假赌

    熱工具

    PhpStorm Mac 版本

    PhpStorm Mac 版本

    最新(2018.2.1 )專業的PHP整合開發工具

    SublimeText3 Linux新版

    SublimeText3 Linux新版

    SublimeText3 Linux最新版

    VSCode Windows 64位元 下載

    VSCode Windows 64位元 下載

    微軟推出的免費、功能強大的一款IDE編輯器

    ZendStudio 13.5.1 Mac

    ZendStudio 13.5.1 Mac

    強大的PHP整合開發環境

    記事本++7.3.1

    記事本++7.3.1

    好用且免費的程式碼編輯器