关于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

发布了22 篇原创文章 · 获赞 12 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/benyuanone/article/details/87937707