關於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。


2.

 

解決方案:

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

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

 

二.由於bean的加載順序和配置文件的關係

1.請參考以下博文

https://blog.csdn.net/J080624/article/details/80508606

https://blog.csdn.net/zhongzunfa/article/details/81988807

https://blog.csdn.net/leileibest_437147623/article/details/80898878

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章